MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / get_file

Method get_file

python/graphvite/dataset.py:182–211  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

180 return save_file
181
182 def get_file(self, key):
183 file_name = os.path.join(self.path, "%s_%s.txt" % (self.name, key))
184 if file_name in self.local_files():
185 return file_name
186
187 urls = self.urls[key]
188 members = self.members[key]
189 preprocess_name = key + "_preprocess"
190 preprocess = getattr(self, preprocess_name, None)
191 if len(urls) > 1 and preprocess is None:
192 raise AttributeError(
193 "There are non-trivial number of files, but function `%s` is not found" % preprocess_name)
194
195 extract_files = []
196 for url, member in zip(urls, members):
197 download_file = self.download(url)
198 extract_file = self.extract(download_file, member)
199 extract_files.append(extract_file)
200 if preprocess:
201 result = preprocess(*(extract_files + [file_name]))
202 if result is not None:
203 return result
204 elif os.path.isfile(extract_files[0]):
205 logger.info("renaming %s to %s" % (self.relpath(extract_files[0]), self.relpath(file_name)))
206 shutil.move(extract_files[0], file_name)
207 else:
208 raise AttributeError(
209 "There are non-trivial number of files, but function `%s` is not found" % preprocess_name)
210
211 return file_name
212
213 def local_files(self):
214 if not os.path.exists(self.path):

Callers 1

__getattr__Method · 0.95

Calls 5

local_filesMethod · 0.95
downloadMethod · 0.95
extractMethod · 0.95
relpathMethod · 0.95
infoMethod · 0.45

Tested by

no test coverage detected