def copy_tree_actions(base: str, include_patterns: t.Union[t.List[str], str] = ["**", "**/.*"],
exclude_patterns: t.List[str] = None) -> t.List[Action]:
"""
Actions for all files and directories in the base directory that match the given patterns.
It's used to copy a whole directory tree.
:param base: base directory
:param include_pattern: patterns that match the paths that should be included
:param exclude_patterns: patterns that match the paths that should be excluded
:return: list of actions
"""
paths = matched_paths(base, include_patterns, exclude_patterns)
files = set() # type: t.Set[str]
dirs = set() # type: t.Set[str]
ret = [] # type: t.List[Action]
for path in paths:
ret.extend(actions_for_dir_path(path, path_acc=dirs))
if os.path.isfile(path) and path not in files:
files.add(path)
ret.append(CopyFile(normalize_path(path)))
return ret
评论列表
文章目录