MCPcopy Index your code
hub / github.com/RustPython/RustPython / glob

Method glob

Lib/pathlib/__init__.py:843–871  ·  view source on GitHub ↗

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

(self, pattern, *, case_sensitive=None, recurse_symlinks=False)

Source from the content-addressed store, hash-verified

841 return (self._from_dir_entry(e, e.path) for e in entries)
842
843 def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
844 """Iterate over this subtree and yield all existing files (of any
845 kind, including directories) matching the given relative pattern.
846 """
847 sys.audit("pathlib.Path.glob", self, pattern)
848 if case_sensitive is None:
849 case_sensitive = self.parser is posixpath
850 case_pedantic = False
851 else:
852 # The user has expressed a case sensitivity choice, but we don't
853 # know the case sensitivity of the underlying filesystem, so we
854 # must use scandir() for everything, including non-wildcard parts.
855 case_pedantic = True
856 parts = self._parse_pattern(pattern)
857 recursive = True if recurse_symlinks else _no_recurse_symlinks
858 globber = _StringGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
859 select = globber.selector(parts[::-1])
860 root = str(self)
861 paths = select(self.parser.join(root, ''))
862
863 # Normalize results
864 if root == '.':
865 paths = map(self._remove_leading_dot, paths)
866 if parts[-1] == '':
867 paths = map(self._remove_trailing_slash, paths)
868 elif parts[-1] == '**':
869 paths = self._filter_trailing_slash(paths)
870 paths = map(self._from_parsed_string, paths)
871 return paths
872
873 def rglob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
874 """Recursively yield all existing files (of any kind, including

Callers 15

rglobMethod · 0.95
test_match_and_globMethod · 0.95
test_glob_recursiveMethod · 0.95
test_glob_dirsMethod · 0.95
test_glob_subdirMethod · 0.95
test_glob_subdirsMethod · 0.95
test_glob_single_charMethod · 0.95
test_glob_charsMethod · 0.95

Calls 7

_StringGlobberClass · 0.90
strFunction · 0.85
_parse_patternMethod · 0.80
selectorMethod · 0.80
selectFunction · 0.50
joinMethod · 0.45