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)
| 1071 | |
| 1072 | |
| 1073 | def find_multifile_paths(path: Path) -> list[Path]: |
| 1074 | '''Given any path belonging to a multi-file model (e.g. foo.bin.1), return |
| 1075 | the whole list of paths in the model. |
| 1076 | ''' |
| 1077 | ret: list[Path] = [] |
| 1078 | for i in itertools.count(): |
| 1079 | nth_path = nth_multifile_path(path, i) |
| 1080 | if nth_path is None: |
| 1081 | break |
| 1082 | ret.append(nth_path) |
| 1083 | if not ret: |
| 1084 | # No matches. This should only happen if the file was named, e.g., |
| 1085 | # foo.0, and there was no file named foo. Oh well, try to process it |
| 1086 | # as a single file. |
| 1087 | return [path] |
| 1088 | return ret |
| 1089 | |
| 1090 | |
| 1091 | def load_some_model(path: Path) -> ModelPlus: |
no test coverage detected