diff options
-rwxr-xr-x | ckandumper | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -23,7 +23,7 @@ import argparse import sys, os, subprocess, pycurl, json from urllib.parse import urlencode -class ckandumper: +class CkanDumper: """Dumps CKAN data: metadata plus entire datasets""" def __init__(self, args): @@ -50,7 +50,7 @@ class ckandumper: elif os.path.exists(dest) and not os.path.isdir(dest): raise ValueError('File exists and is not a folder:' + dest) - def loadJSON(self, file): + def load_json(self, file): descriptor = open(file) data = json.load(descriptor) file.close() @@ -69,7 +69,7 @@ class ckandumper: # Groups # self.download(self.url + self.group_list, group_list) - groups = self.loadJSON(group_list) + groups = self.load_json(group_list) for group in groups['result']: group_folder = self.dest + os.sep + 'groups' + os.sep + group @@ -82,7 +82,7 @@ class ckandumper: # Tags # self.download(self.url + self.tag_list, tag_list) - tags = self.loadJSON(tag_list) + tags = self.load_json(tag_list) for tag in tags['result']: tag_folder = self.dest + os.sep + 'tags' + os.sep + tag @@ -96,7 +96,7 @@ class ckandumper: # Packages # self.download(self.url + self.package_list, package_list) - packages = self.loadJSON(package_list) + packages = self.load_json(package_list) for package in packages['result']: package_folder = self.dest + os.sep + 'packages' + os.sep + package @@ -106,7 +106,7 @@ class ckandumper: print("Downloading " + self.url + self.package_show + 'id=' + package + '...') self.download(self.url + self.package_show + urlencode({ 'id': package }, False, '', 'utf-8'), package_file) - contents = self.loadJSON(package_file) + contents = self.load_json(package_file) for resource in contents['result']['resources']: #if resource['name'] != None: @@ -138,5 +138,5 @@ if __name__ == "__main__": args = parser.parse_args() # Dispatch - ckan = ckandumper(args) + ckan = CkanDumper(args) ckan.dump() |