From cbefbe81d2861102865bf1806e8e3217d2df2b26 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 14 Feb 2012 20:27:17 +0100 Subject: [PATCH] fix bad behaviors --- modules/sachsen/backend.py | 2 +- modules/sachsen/browser.py | 20 +++++++++----------- modules/sachsen/pages.py | 6 ++++-- weboob/applications/flatboob/flatboob.py | 1 + weboob/applications/wetboobs/wetboobs.py | 2 ++ 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/sachsen/backend.py b/modules/sachsen/backend.py index a3ece320bf..2d7c6ed9ba 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 19932019a2..0ced905d7a 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 92b8ad009c..978c8d8a7b 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 3aac3e41d9..eede005a1e 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 37c9f31902..704076541b 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) -- GitLab