MCPcopy Index your code
hub / github.com/python/cpython / glob

Method glob

Lib/pathlib/__init__.py:1041–1069  ·  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

1039 return (self._from_dir_entry(e, e.path) for e in entries)
1040
1041 def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
1042 """Iterate over this subtree and yield all existing files (of any
1043 kind, including directories) matching the given relative pattern.
1044 """
1045 sys.audit("pathlib.Path.glob", self, pattern)
1046 if case_sensitive is None:
1047 case_sensitive = self.parser is posixpath
1048 case_pedantic = False
1049 else:
1050 # The user has expressed a case sensitivity choice, but we don't
1051 # know the case sensitivity of the underlying filesystem, so we
1052 # must use scandir() for everything, including non-wildcard parts.
1053 case_pedantic = True
1054 parts = self._parse_pattern(pattern)
1055 recursive = True if recurse_symlinks else _no_recurse_symlinks
1056 globber = _StringGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
1057 select = globber.selector(parts[::-1])
1058 root = str(self)
1059 paths = select(self.parser.join(root, ''))
1060
1061 # Normalize results
1062 if root == '.':
1063 paths = map(self._remove_leading_dot, paths)
1064 if parts[-1] == '':
1065 paths = map(self._remove_trailing_slash, paths)
1066 elif parts[-1] == '**':
1067 paths = self._filter_trailing_slash(paths)
1068 paths = map(self._from_parsed_string, paths)
1069 return paths
1070
1071 def rglob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
1072 """Recursively yield all existing files (of any kind, including

Callers 15

wasi_sdkFunction · 0.95
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

Calls 7

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