def _iterate_files(self, content): files = [] if 'files' in content: for file_info in content['files']: f = DataFile(self.client, pathJoin(self.path, file_info['filename'])) f.set_attributes(file_info) files.append(f) return files
def test_putNumpy_getNumpy(self): file = ".my/empty/numpy.json" df = DataFile(self.client, 'data://' + file) arr = np.array([0, 0, 0, 0], dtype=np.int64) response = df.putNumpy(arr) self.assertEqual(response.path, file) result = self.client.file(file).getNumpy() self.assertEqual(str(arr), str(result))
def test_set_attributes(self): df = DataFile(self.client, 'data://.my/empty') try: df.set_attributes({ 'last_modified': '2019-01-09T22:44:31.632Z', 'size': 0 }) except Exception as e: self.fail("set_attributes failed with exception: " + str(e))
def test_putJson_getJson(self): file = '.my/empty/test.json' df = DataFile(self.client, 'data://' + file) if sys.version_info[0] < 3: payload = {u"hello": u"world"} else: payload = {"hello": "world"} response = df.putJson(payload) self.assertEqual(response.path, file) result = self.client.file(file).getJson() self.assertEqual(str(result), str(payload))
def file(self, dataUrl): return DataFile(self, dataUrl)
def file(self, name): return DataFile(self.client, pathJoin(self.path, name))
def file(self, dataUrl): if dataUrl.startswith('file://'): return LocalDataFile(self, dataUrl) else: return DataFile(self, dataUrl)