aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-05-14 19:39:46 -0300
committerSilvio Rhatto <rhatto@riseup.net>2019-05-14 19:39:46 -0300
commitf8c6e40555200e1e21964de5dce30ab7f42499a8 (patch)
tree658426b8efd2a0e1be39a20f3196898280ff29fd
parentfb23b97ad02b749fa876785fb032162e35a36c85 (diff)
downloadckandumper-f8c6e40555200e1e21964de5dce30ab7f42499a8.tar.gz
ckandumper-f8c6e40555200e1e21964de5dce30ab7f42499a8.tar.bz2
Coding style
-rwxr-xr-xckandumper14
1 files changed, 7 insertions, 7 deletions
diff --git a/ckandumper b/ckandumper
index 3f8f08e..1facd9c 100755
--- a/ckandumper
+++ b/ckandumper
@@ -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()