def _do_tree(root_src, root_dest, tmpl_dict, tmpl_ext, tag_delim, level=0):
if level == 0:
_mkdir(root_dest)
for entry in os.scandir(root_src):
src_path = os.path.join(root_src, entry.name)
dest_path = os.path.join(root_dest,
do_text(entry.name, tmpl_dict, tag_delim))
if entry.is_dir():
_mkdir(dest_path, copy_stats_from=src_path)
_do_tree(src_path, dest_path, tmpl_dict, tmpl_ext, tag_delim,
level + 1)
elif entry.is_file():
was_tmpl = False
for ext in tmpl_ext:
ext = ext.lower()
if entry.name.lower().endswith(ext):
was_tmpl = True
dest_path = dest_path[0:-len(ext)]
do_file(src_path, dest_path, tmpl_dict, tag_delim)
break
if not was_tmpl:
shutil.copy2(src_path, dest_path, follow_symlinks=False)
评论列表
文章目录