diff --git a/modules/sachsen/backend.py b/modules/sachsen/backend.py index a3ece320bfb794f20d6161d0977833a19cea132f..2d7c6ed9ba49ff7812d1c23eb2f58dc0c570fec4 100644 --- a/modules/sachsen/backend.py +++ b/modules/sachsen/backend.py @@ -35,7 +35,7 @@ class SachsenLevelBackend(BaseBackend, ICapWaterLevel): BROWSER = SachsenBrowser def iter_gauge_history(self, id): - return self.browser.get_history(id) + return self.browser.iter_history(id) def get_last_measure(self, id): return self.browser.last_seen(id) diff --git a/modules/sachsen/browser.py b/modules/sachsen/browser.py index 19932019a26ba3560db6cd5ba54e713b631801b5..0ced905d7af18130161ffaa5b614bef1f52d8409 100644 --- a/modules/sachsen/browser.py +++ b/modules/sachsen/browser.py @@ -43,26 +43,24 @@ def home(self): self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html') def get_rivers_list(self): - if self.cache_list == None: - if not self.is_on_page(ListPage): + if self.cache_list is None: + if not self.is_on_page(ListPage): self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html') self.cache_list = self.page.get_rivers_list() return self.cache_list - def get_history(self, id): + def iter_history(self, id): self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/MP/%d/index.html' %int(id)) - return self.page.get_history() + return self.page.iter_history() - def last_seen(self, id): + def last_seen(self, id): self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/MP/%d/index.html' %int(id)) - return self.page.last_seen() + return self.page.last_seen() def search(self, pattern): - if self.cache_list == None: + if self.cache_list is None: self.get_rivers_list() - l = [] + for gauge in self.cache_list: if gauge.name.__contains__(pattern) or gauge.river.__contains__(pattern): - l.append(gauge) - - return l + yield gauge diff --git a/modules/sachsen/pages.py b/modules/sachsen/pages.py index 92b8ad009cba9f822c13a8165833de51d8a3eb50..978c8d8a7bef72cd68834fb945ca1d5a9abe4394 100644 --- a/modules/sachsen/pages.py +++ b/modules/sachsen/pages.py @@ -27,6 +27,7 @@ class ListPage(BasePage): def get_rivers_list(self): + l = [] for pegel in self.document.getroot().xpath(".//a[@onmouseout='pegelaus()']"): data = pegel.attrib['onmouseover'].strip('pegelein(').strip(')').replace(",'", ",").split("',") gauge = Gauge(int(data[7])) @@ -54,10 +55,11 @@ def get_rivers_list(self): else: gauge.forecast = NotAvailable - yield gauge + l.append(gauge) + return l class HistoryPage(BasePage): - def get_history(self): + def iter_history(self): table = self.document.getroot().cssselect('table[width="215"]') first = True for line in table[0].cssselect("tr"): diff --git a/weboob/applications/flatboob/flatboob.py b/weboob/applications/flatboob/flatboob.py index 3aac3e41d9f172c8b217d970004fcdbe7387d9c5..eede005a1ee357d4eed7265430d4bab294ac34ab 100644 --- a/weboob/applications/flatboob/flatboob.py +++ b/weboob/applications/flatboob/flatboob.py @@ -146,6 +146,7 @@ def do_search(self, line): query.cost_min = self.ask_int('Enter min cost') query.cost_max = self.ask_int('Enter max cost') + self.change_path('/housings') for backend, housing in self.do('search_housings', query): self.add_object(housing) self.format(housing) diff --git a/weboob/applications/wetboobs/wetboobs.py b/weboob/applications/wetboobs/wetboobs.py index 37c9f3190270ae88fdb4618e52d490d0f9e5339f..704076541beeb468bada941845ba48457c773c82 100644 --- a/weboob/applications/wetboobs/wetboobs.py +++ b/weboob/applications/wetboobs/wetboobs.py @@ -96,6 +96,7 @@ def do_cities(self, pattern): Search cities. """ + self.change_path('/cities') for backend, city in self.do('iter_city_search', pattern, caps=ICapWeather): self.add_object(city) self.format(city) @@ -142,6 +143,7 @@ def do_gauges(self, pattern): List all rivers. If PATTERN is specified, search on a pattern. """ + self.change_path('/gauges') for backend, gauge in self.do('iter_gauges', pattern or None, caps=ICapWaterLevel): self.add_object(gauge) self.format(gauge)