Read the index file and returns the uids and filenames.
(self, index_filename: str, with_uid: bool, root_dir: str)
| 115 | return invalid_indexes |
| 116 | |
| 117 | def _read_index_file(self, index_filename: str, with_uid: bool, root_dir: str): |
| 118 | """Read the index file and returns the uids and filenames.""" |
| 119 | |
| 120 | assert os.path.exists(index_filename) |
| 121 | |
| 122 | uids = [] |
| 123 | filenames = [] |
| 124 | with open(index_filename, "r") as f: |
| 125 | for line in f: |
| 126 | line = line.strip() |
| 127 | if with_uid: |
| 128 | uid, filename = line.split(sep=" ", maxsplit=1) |
| 129 | else: |
| 130 | uid, filename = None, line |
| 131 | |
| 132 | # handle root_dir |
| 133 | filename = os.path.join(root_dir, filename) |
| 134 | |
| 135 | uids.append(uid) |
| 136 | filenames.append(filename) |
| 137 | |
| 138 | return uids, filenames |