Given any path belonging to a multi-file model (e.g. foo.bin.1), return the whole list of paths in the model.
(path: Path)
| 1240 | |
| 1241 | |
| 1242 | def find_multifile_paths(path: Path) -> list[Path]: |
| 1243 | '''Given any path belonging to a multi-file model (e.g. foo.bin.1), return |
| 1244 | the whole list of paths in the model. |
| 1245 | ''' |
| 1246 | ret: list[Path] = [] |
| 1247 | for i in itertools.count(): |
| 1248 | nth_path = nth_multifile_path(path, i) |
| 1249 | if nth_path is None: |
| 1250 | break |
| 1251 | ret.append(nth_path) |
| 1252 | if not ret: |
| 1253 | # No matches. This should only happen if the file was named, e.g., |
| 1254 | # foo.0, and there was no file named foo. Oh well, try to process it |
| 1255 | # as a single file. |
| 1256 | return [path] |
| 1257 | return ret |
| 1258 | |
| 1259 | |
| 1260 | def load_some_model(path: Path) -> ModelPlus: |
no test coverage detected