27 lines
733 B
Python
27 lines
733 B
Python
#!/usr/bin/env python
|
||
# -*- coding: utf-8 -*-
|
||
# @Time : 2022/3/28 13:22
|
||
# @Author : 郭林莉
|
||
import os
|
||
|
||
|
||
def get_all_files(file_path, yaml_data_switch=False) -> list:
|
||
"""
|
||
获取文件路径
|
||
:param file_path: 目录路径
|
||
:param yaml_data_switch: 是否过滤文件为 yaml格式, True则过滤
|
||
:return:
|
||
"""
|
||
filename = []
|
||
# 获取所有文件下的子文件名称
|
||
for root, dirs, files in os.walk(file_path):
|
||
for filePath in files:
|
||
path = os.path.join(root, filePath)
|
||
if yaml_data_switch:
|
||
if 'yaml' in path or '.yml' in path:
|
||
filename.append(path)
|
||
else:
|
||
filename.append(path)
|
||
return filename
|
||
|