Expand a list of files/directories into absolute .gz file paths. Paths starting with '@' are treated as files containing one path per line.
(paths: list[str])
| 111 | |
| 112 | |
| 113 | def collect_gz_files(paths: list[str]) -> list[str]: |
| 114 | """Expand a list of files/directories into absolute .gz file paths. |
| 115 | |
| 116 | Paths starting with '@' are treated as files containing one path per line. |
| 117 | """ |
| 118 | expanded = _expand_file_lists(paths) |
| 119 | result: list[str] = [] |
| 120 | for path in expanded: |
| 121 | if os.path.isdir(path): |
| 122 | result.extend( |
| 123 | sorted(glob.glob(os.path.join(path, "**", "*.gz"), recursive=True)) |
| 124 | ) |
| 125 | elif not path.endswith(".gz"): |
| 126 | raise ValueError( |
| 127 | f"expected a .gz file but got '{path}' — did you mean '@{path}'?" |
| 128 | ) |
| 129 | else: |
| 130 | result.append(path) |
| 131 | return [os.path.abspath(p) for p in result] |
| 132 | |
| 133 | |
| 134 | def fmt_tokens(n: int) -> str: |