MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _iglob

Function _iglob

tools/python-3.11.9-amd64/Lib/glob.py:60–99  ·  view source on GitHub ↗
(pathname, root_dir, dir_fd, recursive, dironly,
           include_hidden=False)

Source from the content-addressed store, hash-verified

58 return it
59
60def _iglob(pathname, root_dir, dir_fd, recursive, dironly,
61 include_hidden=False):
62 dirname, basename = os.path.split(pathname)
63 if not has_magic(pathname):
64 assert not dironly
65 if basename:
66 if _lexists(_join(root_dir, pathname), dir_fd):
67 yield pathname
68 else:
69 # Patterns ending with a slash should match only directories
70 if _isdir(_join(root_dir, dirname), dir_fd):
71 yield pathname
72 return
73 if not dirname:
74 if recursive and _isrecursive(basename):
75 yield from _glob2(root_dir, basename, dir_fd, dironly,
76 include_hidden=include_hidden)
77 else:
78 yield from _glob1(root_dir, basename, dir_fd, dironly,
79 include_hidden=include_hidden)
80 return
81 # `os.path.split()` returns the argument itself as a dirname if it is a
82 # drive or UNC path. Prevent an infinite recursion if a drive or UNC path
83 # contains magic characters (i.e. r'\\?\C:').
84 if dirname != pathname and has_magic(dirname):
85 dirs = _iglob(dirname, root_dir, dir_fd, recursive, True,
86 include_hidden=include_hidden)
87 else:
88 dirs = [dirname]
89 if has_magic(basename):
90 if recursive and _isrecursive(basename):
91 glob_in_dir = _glob2
92 else:
93 glob_in_dir = _glob1
94 else:
95 glob_in_dir = _glob0
96 for dirname in dirs:
97 for name in glob_in_dir(_join(root_dir, dirname), basename, dir_fd, dironly,
98 include_hidden=include_hidden):
99 yield os.path.join(dirname, name)
100
101# These 2 helper functions non-recursively glob inside a literal directory.
102# They return a list of basenames. _glob1 accepts a pattern while _glob0

Callers 1

iglobFunction · 0.70

Calls 9

_lexistsFunction · 0.85
_isdirFunction · 0.85
_glob2Function · 0.85
_glob1Function · 0.85
has_magicFunction · 0.70
_joinFunction · 0.70
_isrecursiveFunction · 0.70
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected