fix bad behaviors
This commit is contained in:
parent
a60def6820
commit
cbefbe81d2
5 changed files with 17 additions and 14 deletions
|
|
@ -35,7 +35,7 @@ class SachsenLevelBackend(BaseBackend, ICapWaterLevel):
|
||||||
BROWSER = SachsenBrowser
|
BROWSER = SachsenBrowser
|
||||||
|
|
||||||
def iter_gauge_history(self, id):
|
def iter_gauge_history(self, id):
|
||||||
return self.browser.get_history(id)
|
return self.browser.iter_history(id)
|
||||||
|
|
||||||
def get_last_measure(self, id):
|
def get_last_measure(self, id):
|
||||||
return self.browser.last_seen(id)
|
return self.browser.last_seen(id)
|
||||||
|
|
|
||||||
|
|
@ -43,26 +43,24 @@ class SachsenBrowser(BaseBrowser):
|
||||||
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
||||||
|
|
||||||
def get_rivers_list(self):
|
def get_rivers_list(self):
|
||||||
if self.cache_list == None:
|
if self.cache_list is None:
|
||||||
if not self.is_on_page(ListPage):
|
if not self.is_on_page(ListPage):
|
||||||
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
||||||
self.cache_list = self.page.get_rivers_list()
|
self.cache_list = self.page.get_rivers_list()
|
||||||
return self.cache_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))
|
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))
|
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):
|
def search(self, pattern):
|
||||||
if self.cache_list == None:
|
if self.cache_list is None:
|
||||||
self.get_rivers_list()
|
self.get_rivers_list()
|
||||||
l = []
|
|
||||||
for gauge in self.cache_list:
|
for gauge in self.cache_list:
|
||||||
if gauge.name.__contains__(pattern) or gauge.river.__contains__(pattern):
|
if gauge.name.__contains__(pattern) or gauge.river.__contains__(pattern):
|
||||||
l.append(gauge)
|
yield gauge
|
||||||
|
|
||||||
return l
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ __all__ = ['ListPage', 'HistoryPage']
|
||||||
|
|
||||||
class ListPage(BasePage):
|
class ListPage(BasePage):
|
||||||
def get_rivers_list(self):
|
def get_rivers_list(self):
|
||||||
|
l = []
|
||||||
for pegel in self.document.getroot().xpath(".//a[@onmouseout='pegelaus()']"):
|
for pegel in self.document.getroot().xpath(".//a[@onmouseout='pegelaus()']"):
|
||||||
data = pegel.attrib['onmouseover'].strip('pegelein(').strip(')').replace(",'", ",").split("',")
|
data = pegel.attrib['onmouseover'].strip('pegelein(').strip(')').replace(",'", ",").split("',")
|
||||||
gauge = Gauge(int(data[7]))
|
gauge = Gauge(int(data[7]))
|
||||||
|
|
@ -54,10 +55,11 @@ class ListPage(BasePage):
|
||||||
else:
|
else:
|
||||||
gauge.forecast = NotAvailable
|
gauge.forecast = NotAvailable
|
||||||
|
|
||||||
yield gauge
|
l.append(gauge)
|
||||||
|
return l
|
||||||
|
|
||||||
class HistoryPage(BasePage):
|
class HistoryPage(BasePage):
|
||||||
def get_history(self):
|
def iter_history(self):
|
||||||
table = self.document.getroot().cssselect('table[width="215"]')
|
table = self.document.getroot().cssselect('table[width="215"]')
|
||||||
first = True
|
first = True
|
||||||
for line in table[0].cssselect("tr"):
|
for line in table[0].cssselect("tr"):
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ class Flatboob(ReplApplication):
|
||||||
query.cost_min = self.ask_int('Enter min cost')
|
query.cost_min = self.ask_int('Enter min cost')
|
||||||
query.cost_max = self.ask_int('Enter max cost')
|
query.cost_max = self.ask_int('Enter max cost')
|
||||||
|
|
||||||
|
self.change_path('/housings')
|
||||||
for backend, housing in self.do('search_housings', query):
|
for backend, housing in self.do('search_housings', query):
|
||||||
self.add_object(housing)
|
self.add_object(housing)
|
||||||
self.format(housing)
|
self.format(housing)
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ class WetBoobs(ReplApplication):
|
||||||
|
|
||||||
Search cities.
|
Search cities.
|
||||||
"""
|
"""
|
||||||
|
self.change_path('/cities')
|
||||||
for backend, city in self.do('iter_city_search', pattern, caps=ICapWeather):
|
for backend, city in self.do('iter_city_search', pattern, caps=ICapWeather):
|
||||||
self.add_object(city)
|
self.add_object(city)
|
||||||
self.format(city)
|
self.format(city)
|
||||||
|
|
@ -142,6 +143,7 @@ class WetBoobs(ReplApplication):
|
||||||
|
|
||||||
List all rivers. If PATTERN is specified, search on a 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):
|
for backend, gauge in self.do('iter_gauges', pattern or None, caps=ICapWaterLevel):
|
||||||
self.add_object(gauge)
|
self.add_object(gauge)
|
||||||
self.format(gauge)
|
self.format(gauge)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue