handle city with ,

This commit is contained in:
j 2017-07-19 19:14:47 +02:00
parent 62face2c21
commit 72cda5596d

View file

@ -102,9 +102,16 @@ class Statistics(dict):
if item['location']: if item['location']:
split = ox.geo.split_geoname(item['location']) split = ox.geo.split_geoname(item['location'])
if len(split) == 1: if len(split) == 1:
split.insert(0, None) country = split[0]
if len(split) == 2: city = None
city, country = split elif len(split) >= 2:
city = ', '.join(split[:-1])
country = split[-1]
else:
logger.error('unknown geo value: %s', item['location'])
country = city = None
if country:
country_data = ox.geo.get_country(country) country_data = ox.geo.get_country(country)
continent = country_data.get('continent', '') continent = country_data.get('continent', '')
region = ', '.join([continent, country_data.get('region', '')]) region = ', '.join([continent, country_data.get('region', '')])
@ -116,8 +123,6 @@ class Statistics(dict):
self._increment(self[mode]['country'], country) self._increment(self[mode]['country'], country)
if city: if city:
self._increment(self[mode]['city'], city) self._increment(self[mode]['city'], city)
else:
logger.error('unknown geo value: %s', item['location'])
name = {} name = {}
for key in ['system', 'browser']: for key in ['system', 'browser']: