pytest_api/tools/get_all_files_path.py

27 lines
733 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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