action.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:temci 作者: parttimenerd 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号