[meteofrance] allow to iter forecasts using town name in addition to city id

This commit is contained in:
Bezleputh 2015-07-07 14:23:45 +02:00
commit 74d166037f
2 changed files with 12 additions and 1 deletions

View file

@ -46,4 +46,12 @@ class MeteofranceModule(Module, CapWeather):
return self.browser.iter_city_search(pattern)
def get_city(self, _id):
return find_object(self.iter_city_search(_id), id=_id, error=CityNotFound)
cities = list(self.iter_city_search(_id))
if len(cities) == 0:
raise CityNotFound()
try:
return find_object(cities, id=_id, error=CityNotFound)
except CityNotFound:
return cities[0]