Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions publicdata/censusreporter/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""


import os
import json
from itertools import repeat
from operator import itemgetter
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 8 additions & 4 deletions publicdata/censusreporter/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down