Returns a function that selects direct children of a given path, filtering by pattern.
(self, part, parts)
| 431 | return select_literal |
| 432 | |
| 433 | def wildcard_selector(self, part, parts): |
| 434 | """Returns a function that selects direct children of a given path, |
| 435 | filtering by pattern. |
| 436 | """ |
| 437 | |
| 438 | match = None if part == '*' else self.compile(part) |
| 439 | dir_only = bool(parts) |
| 440 | if dir_only: |
| 441 | select_next = self.selector(parts) |
| 442 | |
| 443 | def select_wildcard(path, exists=False): |
| 444 | try: |
| 445 | entries = self.scandir(path) |
| 446 | except OSError: |
| 447 | pass |
| 448 | else: |
| 449 | for entry, entry_name, entry_path in entries: |
| 450 | if match is None or match(entry_name): |
| 451 | if dir_only: |
| 452 | try: |
| 453 | if not entry.is_dir(): |
| 454 | continue |
| 455 | except OSError: |
| 456 | continue |
| 457 | entry_path = self.concat_path(entry_path, self.sep) |
| 458 | yield from select_next(entry_path, exists=True) |
| 459 | else: |
| 460 | yield entry_path |
| 461 | return select_wildcard |
| 462 | |
| 463 | def recursive_selector(self, part, parts): |
| 464 | """Returns a function that selects a given path and all its children, |