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

Function _iglob

Lib/glob.py:69–108  ·  view source on GitHub ↗
(pathname, root_dir, dir_fd, recursive, dironly,
           include_hidden=False)

Source from the content-addressed store, hash-verified

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

Callers 1

iglobFunction · 0.85

Calls 9

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

Tested by

no test coverage detected