This repository was archived by the owner on Feb 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Allow billy to handle newly-defined Imago boundary sets #257
Closed
mileswwatkins
wants to merge
5
commits into
openstates:master
from
mileswwatkins:miles/feature/ocd_division_handling
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
863b7ce
Allow billy to handle newly-defined Imago boundary sets
mileswwatkins b08c048
Compile the boundary set name regular expression
mileswwatkins 60592d6
Make boundary set matching more precise and accurate
mileswwatkins 14ac499
Add date filtering for find-your-legislator boundaries so that it wor…
mileswwatkins 21746cc
Remove a debug print
mileswwatkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
from piston.handler import BaseHandler, HandlerMetaClass | ||
|
||
AT_LARGE = ['At-Large', 'Chairman'] | ||
ACTIVE_BOUNDARY_SETS = settings.BOUNDARY_SERVICE_SETS.split(",") | ||
ACTIVE_BOUNDARY_SETS_RE = settings.BOUNDARY_SERVICE_SETS | ||
|
||
|
||
_lower_fields = (settings.LEVEL_FIELD, 'chamber') | ||
|
@@ -402,17 +402,12 @@ def read(self, request): | |
|
||
for dist in resp['results']: | ||
ocdid = dist['id'] | ||
# ocd-division/country:us/state:oh/cd:11 | ||
_, localpart = ocdid.rsplit("/", 1) | ||
set_, series = localpart.split(":", 1) | ||
if set_ not in ['sldl', 'sldu', 'ward']: | ||
# Place, CD, County, ... | ||
continue | ||
|
||
districts = db.districts.find({'division_id': ocdid}) | ||
count = districts.count() | ||
|
||
if count == 1: | ||
if count == 0: | ||
continue | ||
elif count == 1: | ||
district = districts[0] | ||
boundary_id = district['division_id'] | ||
|
||
|
@@ -425,7 +420,7 @@ def read(self, request): | |
district['chamber'])] = boundary_id | ||
|
||
jurisdiction = district['abbr'] | ||
elif count != 0: | ||
else: | ||
raise ValueError('multiple districts with boundary_id: %s' % | ||
boundary_id) | ||
|
||
|
@@ -490,7 +485,7 @@ def _ocd_id_to_shape_url(self, ocd_id): | |
) | ||
data = json.load(urllib2.urlopen(url)) | ||
geometries = filter( | ||
lambda x: x['boundary_set']['name'] in ACTIVE_BOUNDARY_SETS, | ||
lambda x: re.search(ACTIVE_BOUNDARY_SETS_RE, x['boundary_set']['name']), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should perhaps do a re.match + handling for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhh, never mind, apparently not in the version I pushed :) |
||
data['geometries'] | ||
) | ||
if len(geometries) == 1: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we
re.compile
this?