paths.py 文件源码

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

项目:xphyle 作者: jdidion 项目源码 文件源码
def find(
            self, root: PathLike = None, 
            path_types: Sequence[PathTypeArg] = 'f',
            recursive: bool = False) -> Sequence[PathInst]:
        """Find all paths matching this PathSpec. The search starts in 'root'
        if it is not None, otherwise it starts in the deepest fixed directory
        of this PathSpec's DirSpec.

        Args:
            root: Directory in which to begin the search.
            path_types: Types to return -- files ('f'), directories ('d') or
                both ('fd').
            recursive: Whether to search recursively.

        Returns:
            A sequence of PathInst.
        """
        if root is None:
            if self.fixed_dir:
                root = str(self.dir_spec)
            else:
                root = self.dir_spec.default_search_root()

        files = find(
            root, self.pattern, path_types=path_types, recursive=recursive,
            return_matches=True)

        return [
            path_inst(path, match_to_dict(match, self.path_vars))
            for path, match in cast(Sequence[Tuple[str, Match[str]]], files)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号