def get_from_paths(sub_path, file_pattern):
"""
Search through the AUTOCOMPOSE_PATHs for files in the sub-path which match the given file_pattern
:param sub_path: The sub-path to look for files in each autocompose path directory.
:param file_pattern: A pattern to match files.
:return: A list of files.
"""
paths = os.environ['AUTOCOMPOSE_PATH'].split(":")
results = []
for path in paths:
try:
files = os.listdir(path=os.path.join(path, sub_path))
for file in files:
if re.fullmatch(file_pattern, file):
results.append(os.path.join(path, sub_path, file_pattern))
except FileNotFoundError:
pass
return results
评论列表
文章目录