def search_file(root_dir, base_name):
# This won't work with python < 3.5
found = []
base_name = glob.escape(base_name)
beforext, _, ext = base_name.rpartition('.')
if ext.lower() in VIDEO_FILES_EXT:
protected_path = os.path.join(root_dir, "**", "*" + beforext + "*" + ext)
else:
protected_path = os.path.join(root_dir, "**", "*" + beforext + "*")
protected_path = protected_path
log.debug("Searching %r", protected_path)
for filename in glob.iglob(protected_path, recursive=True):
log.debug("Found: %s", filename)
found.append(filename)
return found
评论列表
文章目录