aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-05-15 10:21:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2019-05-15 10:21:51 -0300
commite4c88334af4172b46774fba1a1226cb88e7c71f6 (patch)
tree6326d997898fc7eb8de7edca93da2645efc34d39
parentf8c6e40555200e1e21964de5dce30ab7f42499a8 (diff)
downloadckandumper-e4c88334af4172b46774fba1a1226cb88e7c71f6.tar.gz
ckandumper-e4c88334af4172b46774fba1a1226cb88e7c71f6.tar.bz2
Docstrings
-rwxr-xr-xckandumper10
1 files 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.')