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)]
评论列表
文章目录