diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-05-15 10:21:51 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-05-15 10:21:51 -0300 |
commit | e4c88334af4172b46774fba1a1226cb88e7c71f6 (patch) | |
tree | 6326d997898fc7eb8de7edca93da2645efc34d39 | |
parent | f8c6e40555200e1e21964de5dce30ab7f42499a8 (diff) | |
download | ckandumper-e4c88334af4172b46774fba1a1226cb88e7c71f6.tar.gz ckandumper-e4c88334af4172b46774fba1a1226cb88e7c71f6.tar.bz2 |
Docstrings
-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.') |