diff options
-rwxr-xr-x | ckandumper | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -39,23 +39,28 @@ class CkanDumper: if args.limit_rate != None: self.limit_rate = '--limit-rate=' + args.limit_rate - # Using wget as it is more reliable def download(self, url, local_filename): + """Downloads a file. + + Using wget as it is more reliable + """ subprocess.call('/usr/bin/wget ' + self.limit_rate + ' -c -O "' + local_filename + '" ' + url, shell=True) def ensuredir(self, dest): - # Ensure that the destination folder exists + """Ensures that the destination folder exists""" if not os.path.exists(dest) and not os.path.isdir(dest): os.makedirs(dest, 0o755); elif os.path.exists(dest) and not os.path.isdir(dest): raise ValueError('File exists and is not a folder:' + dest) def load_json(self, file): + """Loads a file with contents serialized as JSON""" descriptor = open(file) data = json.load(descriptor) file.close() def dump(self): + """Downloads all content listed in a CKAN repository""" self.ensuredir(self.dest) # Move to dest folder @@ -128,7 +133,6 @@ class CkanDumper: # Run only once during development #return -# Standalone usage if __name__ == "__main__": # Parse CLI parser = argparse.ArgumentParser(description='Dump CKAN metadata and datasets.') |