Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive i
(pathname, *, root_dir=None, dir_fd=None, recursive=False,
include_hidden=False)
| 29 | include_hidden=include_hidden)) |
| 30 | |
| 31 | def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False, |
| 32 | include_hidden=False): |
| 33 | """Return an iterator which yields the paths matching a pathname pattern. |
| 34 | |
| 35 | The pattern may contain simple shell-style wildcards a la |
| 36 | fnmatch. However, unlike fnmatch, filenames starting with a |
| 37 | dot are special cases that are not matched by '*' and '?' |
| 38 | patterns. |
| 39 | |
| 40 | If recursive is true, the pattern '**' will match any files and |
| 41 | zero or more directories and subdirectories. |
| 42 | """ |
| 43 | sys.audit("glob.glob", pathname, recursive) |
| 44 | sys.audit("glob.glob/2", pathname, recursive, root_dir, dir_fd) |
| 45 | if root_dir is not None: |
| 46 | root_dir = os.fspath(root_dir) |
| 47 | else: |
| 48 | root_dir = pathname[:0] |
| 49 | it = _iglob(pathname, root_dir, dir_fd, recursive, False, |
| 50 | include_hidden=include_hidden) |
| 51 | if not pathname or recursive and _isrecursive(pathname[:2]): |
| 52 | try: |
| 53 | s = next(it) # skip empty string |
| 54 | if s: |
| 55 | it = itertools.chain((s,), it) |
| 56 | except StopIteration: |
| 57 | pass |
| 58 | return it |
| 59 | |
| 60 | def _iglob(pathname, root_dir, dir_fd, recursive, dironly, |
| 61 | include_hidden=False): |
no test coverage detected