MCPcopy Create free account
hub / github.com/apple/ml-pointersect / _read_index_file

Method _read_index_file

cdslib/core/data/index_reader.py:117–138  ·  view source on GitHub ↗

Read the index file and returns the uids and filenames.

(self, index_filename: str, with_uid: bool, root_dir: str)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected