From e4c88334af4172b46774fba1a1226cb88e7c71f6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 15 May 2019 10:21:51 -0300 Subject: Docstrings --- ckandumper | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ckandumper b/ckandumper index 1facd9c..d70f35f 100755 --- a/ckandumper +++ b/ckandumper @@ -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.') -- cgit v1.2.3