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

Function _walk_dir

Lib/compileall.py:25–46  ·  view source on GitHub ↗
(dir, maxlevels, quiet=0)

Source from the content-addressed store, hash-verified

23__all__ = ["compile_dir","compile_file","compile_path"]
24
25def _walk_dir(dir, maxlevels, quiet=0):
26 if quiet < 2 and isinstance(dir, os.PathLike):
27 dir = os.fspath(dir)
28 if not quiet:
29 print('Listing {!r}...'.format(dir))
30 try:
31 names = os.listdir(dir)
32 except OSError:
33 if quiet < 2:
34 print("Can't list {!r}".format(dir))
35 names = []
36 names.sort()
37 for name in names:
38 if name == '__pycache__':
39 continue
40 fullname = os.path.join(dir, name)
41 if not os.path.isdir(fullname):
42 yield fullname
43 elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
44 os.path.isdir(fullname) and not os.path.islink(fullname)):
45 yield from _walk_dir(fullname, maxlevels=maxlevels - 1,
46 quiet=quiet)
47
48def compile_dir(dir, maxlevels=None, ddir=None, force=False,
49 rx=None, quiet=0, legacy=False, optimize=-1, workers=1,

Callers 1

compile_dirFunction · 0.85

Calls 6

listdirMethod · 0.80
islinkMethod · 0.80
formatMethod · 0.45
sortMethod · 0.45
joinMethod · 0.45
isdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…