Args: index_filename: the index file that lists all the data, one per line. with_uid: If with_uid is True, each line is composed of `a_unique_id_of_the_data filename_of_the_data`. If with_uid is False,
(self, index_filename: str, with_uid: bool, root_dir: str = None)
| 34 | """ |
| 35 | |
| 36 | def __init__(self, index_filename: str, with_uid: bool, root_dir: str = None): |
| 37 | """ |
| 38 | Args: |
| 39 | index_filename: |
| 40 | the index file that lists all the data, one per line. |
| 41 | with_uid: |
| 42 | If with_uid is True, each line is composed of |
| 43 | `a_unique_id_of_the_data filename_of_the_data`. |
| 44 | If with_uid is False, each line is composed of |
| 45 | `filename_of_the_data`. |
| 46 | root_dir: |
| 47 | The root folder for the files listed in the index_filename. |
| 48 | For example, if root_dir = 'a/b' and index_filename[0] = 'c/d.npy', |
| 49 | the file is at 'a/b/c/d.npy'. |
| 50 | If None is given, use the folder of the index_filename as root_dir. |
| 51 | If '' is given, no modification will be made. |
| 52 | """ |
| 53 | self.index_filename = index_filename |
| 54 | self.with_uid = with_uid |
| 55 | self.root_dir = root_dir |
| 56 | if self.root_dir is None: |
| 57 | self.root_dir = os.path.dirname(self.index_filename) |
| 58 | |
| 59 | # read the index file |
| 60 | self.uids, self.filenames = self._read_index_file( |
| 61 | index_filename=self.index_filename, |
| 62 | with_uid=self.with_uid, |
| 63 | root_dir=self.root_dir, |
| 64 | ) |
| 65 | |
| 66 | def __len__(self): |
| 67 | """Returns the number of files in the index file.""" |
nothing calls this directly
no test coverage detected