diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-05-25 11:22:31 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-05-25 11:22:31 +0100 |
commit | 4e0652313e183e4d74a49ea48ad4967a6576238e (patch) | |
tree | ca9ad5b7f738cb251206b5ffe2ef5af94284317c | |
parent | cc7c785bf5a96efa883565f03cfadd35ada6177b (diff) |
Cope with null council.
-rwxr-xr-x | bin/kasabi | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/kasabi b/bin/kasabi index 5b99ba4ff..456b2f4d1 100755 --- a/bin/kasabi +++ b/bin/kasabi @@ -63,7 +63,7 @@ def main(): report['detail'] = tidy_string(report['detail']) report['confirmed'] = report['confirmed'].replace(microsecond=0).isoformat() # Don't want microseconds report['lastupdate'] = report['lastupdate'].replace(microsecond=0).isoformat() - report['council'] = sorted(re.sub('\|.*', '', report['council']).split(',')) # Remove missing councils + report['council'] = sorted(re.sub('\|.*', '', report['council'] or '').split(',')) # Remove missing councils # Fetch updates to note state changes states = [ { 'state': 'confirmed', 'time': report['confirmed'] } ] @@ -166,6 +166,7 @@ class FixMyStreetChangeSet(object): # Get info for the councils council_data = { 'sentTo': '', 'areaNames': [] } for council in report['council']: + if not council: continue js = json.load(urllib.urlopen('http://mapit.mysociety.org/area/{0}'.format(council))) os_id = int(js['codes']['unit_id']) + 7000000000000000 if report['whensent']: @@ -173,6 +174,7 @@ class FixMyStreetChangeSet(object): council_data['areaNames'].append(js['name']) council_data.setdefault('firstCouncil', council) council_data['areaNames'] = ' / '.join(council_data['areaNames']) + council_data.setdefault('firstCouncil', '0') # easting/northing |