MCPcopy Index your code
hub / github.com/algorithmiaio/algorithmia-python / getFile

Method getFile

Algorithmia/datafile.py:37–52  ·  view source on GitHub ↗
(self, as_path=False)

Source from the content-addressed store, hash-verified

35
36 # Get file from the data api
37 def getFile(self, as_path=False):
38 exists, error = self.existsWithError()
39 if not exists:
40 raise DataApiError('unable to get file {} - {}'.format(self.path, error))
41 # Make HTTP get request
42 response = self.client.getHelper(self.url)
43 with tempfile.NamedTemporaryFile(delete=False) as f:
44 for block in response.iter_content(1024):
45 if not block:
46 break
47 f.write(block)
48 f.flush()
49 if as_path:
50 return f.name
51 else:
52 return open(f.name)
53
54 def getAsZip(self):
55 """Download/decompress file/directory and return path to file/directory.

Callers 12

getAsZipMethod · 0.95
freezeMethod · 0.45
readMethod · 0.45
readlineMethod · 0.45
readlinesMethod · 0.45
tellMethod · 0.45
seekMethod · 0.45
cpMethod · 0.45
getDirMethod · 0.45
test_get_nonexistantMethod · 0.45
test_get_nonexistantMethod · 0.45
test_read_typesMethod · 0.45

Calls 3

existsWithErrorMethod · 0.95
DataApiErrorClass · 0.90
getHelperMethod · 0.80

Tested by 3

test_get_nonexistantMethod · 0.36
test_get_nonexistantMethod · 0.36
test_read_typesMethod · 0.36