def traverse(path, ignore_files=None):
if not os.path.exists(path):
return
if ignore_files is None:
ignore_files = []
for item in scandir(path):
if any(fnmatch.fnmatch(item.name, pattern) for pattern in ignore_files):
logger.debug('Ignoring %s', item)
continue
if item.is_dir():
for result in traverse(item.path, ignore_files):
yield os.path.join(item.name, result)
else:
yield item.name
评论列表
文章目录