handle city with ,
This commit is contained in:
parent
62face2c21
commit
72cda5596d
1 changed files with 12 additions and 7 deletions
|
@ -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', '')])
|
||||||
|
@ -114,10 +121,8 @@ class Statistics(dict):
|
||||||
self._increment(self[mode]['continent'], continent)
|
self._increment(self[mode]['continent'], continent)
|
||||||
self._increment(self[mode]['region'], region)
|
self._increment(self[mode]['region'], region)
|
||||||
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']:
|
||||||
|
|
Loading…
Reference in a new issue