Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
(
patterns: Iterable[str], version: str
)
| 67 | |
| 68 | |
| 69 | def _resolve_files_and_regexes( |
| 70 | patterns: Iterable[str], version: str |
| 71 | ) -> Generator[tuple[str, re.Pattern], None, None]: |
| 72 | """ |
| 73 | Resolve all distinct files with their regexp from a list of glob patterns with optional regexp |
| 74 | """ |
| 75 | filepath_set: set[tuple[str, str]] = set() |
| 76 | for pattern in patterns: |
| 77 | drive, tail = os.path.splitdrive(pattern) |
| 78 | path, _, regex = tail.partition(":") |
| 79 | filepath = drive + path |
| 80 | regex = regex or re.escape(version) |
| 81 | |
| 82 | filepath_set.update((path, regex) for path in iglob(filepath)) |
| 83 | |
| 84 | return ((path, re.compile(regex)) for path, regex in sorted(filepath_set)) |
| 85 | |
| 86 | |
| 87 | def create_commit_message( |
no test coverage detected