(
subpath: str, excludes: list[str], fscache: FileSystemCache, verbose: bool
)
| 675 | |
| 676 | |
| 677 | def matches_exclude( |
| 678 | subpath: str, excludes: list[str], fscache: FileSystemCache, verbose: bool |
| 679 | ) -> bool: |
| 680 | if not excludes: |
| 681 | return False |
| 682 | subpath_str = os.path.relpath(subpath).replace(os.sep, "/") |
| 683 | if fscache.isdir(subpath): |
| 684 | subpath_str += "/" |
| 685 | for exclude in excludes: |
| 686 | try: |
| 687 | if re.search(exclude, subpath_str): |
| 688 | if verbose: |
| 689 | print( |
| 690 | f"TRACE: Excluding {subpath_str} (matches pattern {exclude})", |
| 691 | file=sys.stderr, |
| 692 | ) |
| 693 | return True |
| 694 | except re.error as e: |
| 695 | print( |
| 696 | f"error: The exclude {exclude} is an invalid regular expression, because: {e}" |
| 697 | + ( |
| 698 | "\n(Hint: use / as a path separator, even if you're on Windows!)" |
| 699 | if "\\" in exclude |
| 700 | else "" |
| 701 | ) |
| 702 | + "\nFor more information on Python's flavor of regex, see:" |
| 703 | + " https://docs.python.org/3/library/re.html", |
| 704 | file=sys.stderr, |
| 705 | ) |
| 706 | sys.exit(2) |
| 707 | return False |
| 708 | |
| 709 | |
| 710 | def matches_gitignore(subpath: str, fscache: FileSystemCache, verbose: bool) -> bool: |
no test coverage detected
searching dependent graphs…