def find(
self, root: PathLike = None,
recursive: bool = False) -> Sequence[PathInst]:
"""Find all paths in `root` matching this spec.
Args:
root: Directory in which to begin the search.
recursive: Whether to search recursively.
Returns:
A sequence of PathInst.
"""
if root is None:
root = self.default_search_root()
find_results = find(
root, self.pattern, path_types=[self.path_type],
recursive=recursive, return_matches=True)
matches = dict(
(path, self._match_to_dict(match, errors=False))
for path, match in cast(
Sequence[Tuple[str, Match[str]]], find_results))
return [
path_inst(path, match)
for path, match in matches.items()
if match is not None]
评论列表
文章目录