From 72cda5596da45e9816da71a2aa0b9ee47c6e2e6f Mon Sep 17 00:00:00 2001 From: j Date: Wed, 19 Jul 2017 19:14:47 +0200 Subject: [PATCH] handle city with , --- pandora/user/statistics.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pandora/user/statistics.py b/pandora/user/statistics.py index 67c0ebf6..c39388f2 100644 --- a/pandora/user/statistics.py +++ b/pandora/user/statistics.py @@ -102,9 +102,16 @@ class Statistics(dict): if item['location']: split = ox.geo.split_geoname(item['location']) if len(split) == 1: - split.insert(0, None) - if len(split) == 2: - city, country = split + country = split[0] + city = None + 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) continent = country_data.get('continent', '') region = ', '.join([continent, country_data.get('region', '')]) @@ -114,10 +121,8 @@ class Statistics(dict): self._increment(self[mode]['continent'], continent) self._increment(self[mode]['region'], region) self._increment(self[mode]['country'], country) - if city: - self._increment(self[mode]['city'], city) - else: - logger.error('unknown geo value: %s', item['location']) + if city: + self._increment(self[mode]['city'], city) name = {} for key in ['system', 'browser']: