Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
(self, pattern, *, case_sensitive=None, recurse_symlinks=False)
| 841 | return (self._from_dir_entry(e, e.path) for e in entries) |
| 842 | |
| 843 | def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=False): |
| 844 | """Iterate over this subtree and yield all existing files (of any |
| 845 | kind, including directories) matching the given relative pattern. |
| 846 | """ |
| 847 | sys.audit("pathlib.Path.glob", self, pattern) |
| 848 | if case_sensitive is None: |
| 849 | case_sensitive = self.parser is posixpath |
| 850 | case_pedantic = False |
| 851 | else: |
| 852 | # The user has expressed a case sensitivity choice, but we don't |
| 853 | # know the case sensitivity of the underlying filesystem, so we |
| 854 | # must use scandir() for everything, including non-wildcard parts. |
| 855 | case_pedantic = True |
| 856 | parts = self._parse_pattern(pattern) |
| 857 | recursive = True if recurse_symlinks else _no_recurse_symlinks |
| 858 | globber = _StringGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive) |
| 859 | select = globber.selector(parts[::-1]) |
| 860 | root = str(self) |
| 861 | paths = select(self.parser.join(root, '')) |
| 862 | |
| 863 | # Normalize results |
| 864 | if root == '.': |
| 865 | paths = map(self._remove_leading_dot, paths) |
| 866 | if parts[-1] == '': |
| 867 | paths = map(self._remove_trailing_slash, paths) |
| 868 | elif parts[-1] == '**': |
| 869 | paths = self._filter_trailing_slash(paths) |
| 870 | paths = map(self._from_parsed_string, paths) |
| 871 | return paths |
| 872 | |
| 873 | def rglob(self, pattern, *, case_sensitive=None, recurse_symlinks=False): |
| 874 | """Recursively yield all existing files (of any kind, including |