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

Function _rglob

PC/layout/support/filesets.py:70–88  ·  view source on GitHub ↗
(root, pattern, condition)

Source from the content-addressed store, hash-verified

68
69
70def _rglob(root, pattern, condition):
71 dirs = [root]
72 recurse = pattern[:3] in {"**/", "**\\"}
73 if recurse:
74 pattern = pattern[3:]
75
76 while dirs:
77 d = dirs.pop(0)
78 if recurse:
79 dirs.extend(
80 filter(
81 condition, (type(root)(f2) for f2 in os.scandir(d) if f2.is_dir())
82 )
83 )
84 yield from (
85 (f.relative_to(root), f)
86 for f in d.glob(pattern)
87 if f.is_file() and condition(f)
88 )
89
90
91def _return_true(f):

Callers 1

rglobFunction · 0.85

Calls 8

filterFunction · 0.50
popMethod · 0.45
extendMethod · 0.45
scandirMethod · 0.45
is_dirMethod · 0.45
relative_toMethod · 0.45
globMethod · 0.45
is_fileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…