def scantree(path_name, skip_list=None):
"""This function returns the files present in path_name, including the
files present in subfolders.
Implementation uses scandir, if available, as it is faster than
os.walk"""
if skip_list is None:
skip_list = DEFAULT_SKIP_LIST
try:
for entry in (e for e in scandir(path_name)
if not is_ignored(e.path, skip_list)):
if entry.is_dir(follow_symlinks=False):
yield from scantree(entry.path, skip_list)
else:
yield entry.path
except PermissionError:
yield 'PermissionError reading {}'.format(path_name)
评论列表
文章目录