| Conditions | 8 |
| Total Lines | 16 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # SPDX-FileCopyrightText: 2020 Peter Bittner <[email protected]> |
||
| 18 | def should_ignore(path: Path, ignore_patterns: list[str]) -> bool: |
||
| 19 | if not ignore_patterns: |
||
| 20 | return False |
||
| 21 | |||
| 22 | for pattern in ignore_patterns: |
||
| 23 | pattern_parts = Path(normalize(pattern)).parts |
||
| 24 | if len(pattern_parts) > 1: |
||
| 25 | if len(path.parts) < len(pattern_parts): |
||
| 26 | continue |
||
| 27 | for i in range(len(path.parts) - len(pattern_parts) + 1): |
||
| 28 | path_slice = path.parts[i : i + len(pattern_parts)] |
||
| 29 | if path_slice == pattern_parts: |
||
| 30 | return True |
||
| 31 | elif path.name == pattern: |
||
| 32 | return True |
||
| 33 | return False |
||
| 34 | |||
| 51 |