add geo.split_geoname

This commit is contained in:
rolux 2013-08-18 11:56:48 +02:00
parent 3cc5659310
commit f429ed8b07

View file

@ -1929,3 +1929,19 @@ def normalize_country_name(country_name):
name = country['name'] name = country['name']
break break
return name and name.decode('utf-8') return name and name.decode('utf-8')
def split_geoname(geoname):
if isinstance(geoname, unicode):
geoname = geoname.encode('utf-8')
countries = [
'Bonaire, Sint Eustatius and Saba',
'Saint Helena, Ascension and Tristan da Cunha'
]
for country in countries:
if geoname.endswith(country):
geoname = geoname.replace(country, country.replace(', ', '; '))
split = geoname.split(', ')
for country in countries:
if geoname.endswith(country.replace(', ', '; ')):
split[-1] = country
return split