def main(self): """ Retrieve the files in a dataset from Citrination. """ url = determine_url(self.params.host, self.params.project) client = citrination_client.CitrinationClient(self.params.api_key, url) directory_name = 'citrination-files-' + str(time.time()).split(".")[0] if self.params.latest: files = client.get_dataset_files(self.params.dataset_id, True) else: files = client.get_dataset_files(self.params.dataset_id) if files and self.params.latest: files_arr = files['files'] if not make_directory(directory_name): return false for file in files_arr: download_file(file['url'], file['filename'], directory_name) elif files: if not make_directory(directory_name): return false versions_arr = files['versions'] for version in versions_arr: files_arr = version['files'] versioned_dir_name = directory_name + "/version_" + str(version['id']) make_directory(versioned_dir_name) for file in files_arr: download_file(file['url'], file['filename'], versioned_dir_name)
def main(self): """ Retrieve a file from a dataset from Citrination. """ url = determine_url(self.params.host, self.params.project) client = citrination_client.CitrinationClient(self.params.api_key, url) if self.params.set_version != None: file = client.get_dataset_file(self.params.dataset_id, self.params.file_path, self.params.set_version) else: file = client.get_dataset_file(self.params.dataset_id, self.params.file_path) if file: file = file['file'] directory_name = 'citrination-files-' + str(time.time()).split(".")[0] make_directory(directory_name) download_file(file['url'], file['filename'], directory_name)