(pathname, root_dir, dir_fd, recursive, dironly,
include_hidden=False)
| 88 | return it |
| 89 | |
| 90 | def _iglob(pathname, root_dir, dir_fd, recursive, dironly, |
| 91 | include_hidden=False): |
| 92 | dirname, basename = os.path.split(pathname) |
| 93 | if not has_magic(pathname): |
| 94 | assert not dironly |
| 95 | if basename: |
| 96 | if _lexists(_join(root_dir, pathname), dir_fd): |
| 97 | yield pathname |
| 98 | else: |
| 99 | # Patterns ending with a slash should match only directories |
| 100 | if _isdir(_join(root_dir, dirname), dir_fd): |
| 101 | yield pathname |
| 102 | return |
| 103 | if not dirname: |
| 104 | if recursive and _isrecursive(basename): |
| 105 | yield from _glob2(root_dir, basename, dir_fd, dironly, |
| 106 | include_hidden=include_hidden) |
| 107 | else: |
| 108 | yield from _glob1(root_dir, basename, dir_fd, dironly, |
| 109 | include_hidden=include_hidden) |
| 110 | return |
| 111 | # `os.path.split()` returns the argument itself as a dirname if it is a |
| 112 | # drive or UNC path. Prevent an infinite recursion if a drive or UNC path |
| 113 | # contains magic characters (i.e. r'\\?\C:'). |
| 114 | if dirname != pathname and has_magic(dirname): |
| 115 | dirs = _iglob(dirname, root_dir, dir_fd, recursive, True, |
| 116 | include_hidden=include_hidden) |
| 117 | else: |
| 118 | dirs = [dirname] |
| 119 | if has_magic(basename): |
| 120 | if recursive and _isrecursive(basename): |
| 121 | glob_in_dir = _glob2 |
| 122 | else: |
| 123 | glob_in_dir = _glob1 |
| 124 | else: |
| 125 | glob_in_dir = _glob0 |
| 126 | for dirname in dirs: |
| 127 | for name in glob_in_dir(_join(root_dir, dirname), basename, dir_fd, dironly, |
| 128 | include_hidden=include_hidden): |
| 129 | yield os.path.join(dirname, name) |
| 130 | |
| 131 | # These 2 helper functions non-recursively glob inside a literal directory. |
| 132 | # They return a list of basenames. _glob1 accepts a pattern while _glob0 |
no test coverage detected
searching dependent graphs…