diff --git a/publicdata/censusreporter/generator.py b/publicdata/censusreporter/generator.py index 9488ba9..72f1a81 100644 --- a/publicdata/censusreporter/generator.py +++ b/publicdata/censusreporter/generator.py @@ -6,6 +6,7 @@ """ +import os import json from itertools import repeat from operator import itemgetter @@ -14,6 +15,10 @@ from publicdata.censusreporter.jsonurl import CensusReporterJsonUrl from rowgenerators import Source +#DEBUG +import inspect +from appurl.util import debug_print +## class CensusReporterSource(Source): """A RowGenerator source that can be registered for Census REporter URLs. @@ -37,9 +42,13 @@ def __init__(self, ref, cache=None, working_dir=None, **kwargs): super().__init__(ref, cache, working_dir, **kwargs) self._source_url = kwargs.get('source_url') - + assert isinstance(ref, CensusReporterJsonUrl) + #DEBUG + #debug_print(self.ref.target_file, inspect.getframeinfo(inspect.currentframe()).filename, inspect.getframeinfo(inspect.currentframe()).lineno) + ## + @property def columns(self): """ Returns columns for the file accessed by accessor. @@ -81,9 +90,9 @@ def get_cr_rows(self): :param kwargs: Catchall so dict can be expanded into the signature. :return: """ - - table_id, summary_level, geoid = unquote(self.ref.target_file).split('/') - + + table_id, summary_level, geoid = unquote(self.ref.target_file).split('/') + with open(self.ref.path) as f: data = json.load(f) diff --git a/publicdata/censusreporter/url.py b/publicdata/censusreporter/url.py index 0370e9a..ced49ab 100644 --- a/publicdata/censusreporter/url.py +++ b/publicdata/censusreporter/url.py @@ -14,6 +14,10 @@ from appurl import WebUrl, AppUrlError, parse_app_url from publicdata.censusreporter.jsonurl import CensusReporterJsonUrl +#DEBUG +import inspect +from appurl.util import debug_print +## class CensusReporterURL(WebUrl): """A URL for censusreporter tables. @@ -95,9 +99,9 @@ def get_resource(self): if cache: cache.makedirs(dirname(self.cache_key), recreate=True) cache.settext(self.cache_key, json.dumps(data, indent=4)) - - return parse_app_url(cache.getsyspath(self.cache_key), - fragment=[join(*self._parts),None], + + return parse_app_url(cache.getsyspath(self.cache_key), + fragment=["/".join(self._parts),None], ).as_type(CensusReporterJsonUrl) def get_target(self): @@ -187,7 +191,7 @@ def get_resource(self): # The downloaded file doesn't have a .zip extension, so Fiona won't recognize # it as a Shapeilfe ZIP archive. So, just make a link. - p = r.inner.path + p = r.inner.path pz = p+'.zip' if exists(pz): diff --git a/setup.py b/setup.py index 13a6bcb..a8d7d5a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='publicdata', - version='0.1.4', + version='0.1.5', url='https://github.com/CivicKnowledge/publicdata', license='MIT', author='Eric Busboom',