Fix conversion warning and remove useless cache
This commit is contained in:
parent
62bb1321bc
commit
996f1e0c22
2 changed files with 10 additions and 17 deletions
|
|
@ -34,8 +34,6 @@ class SachsenBrowser(BaseBrowser):
|
|||
'.*hwz/MP/.*': HistoryPage
|
||||
}
|
||||
|
||||
cache_list = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
BaseBrowser.__init__(self, *args, **kwargs)
|
||||
|
||||
|
|
@ -43,11 +41,9 @@ class SachsenBrowser(BaseBrowser):
|
|||
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
||||
|
||||
def get_rivers_list(self):
|
||||
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
|
||||
if not self.is_on_page(ListPage):
|
||||
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html')
|
||||
return self.page.get_rivers_list()
|
||||
|
||||
def iter_history(self, id):
|
||||
self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/MP/%d/index.html' % int(id))
|
||||
|
|
@ -58,9 +54,6 @@ class SachsenBrowser(BaseBrowser):
|
|||
return self.page.last_seen()
|
||||
|
||||
def search(self, pattern):
|
||||
if self.cache_list is None:
|
||||
self.get_rivers_list()
|
||||
|
||||
for gauge in self.cache_list:
|
||||
if gauge.name.__contains__(pattern) or gauge.river.__contains__(pattern):
|
||||
for gauge in self.get_rivers_list():
|
||||
if pattern in gauge.name or pattern in gauge.river:
|
||||
yield gauge
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class ListPage(BasePage):
|
|||
for pegel in self.document.getroot().xpath(".//a[@onmouseout='pegelaus()']"):
|
||||
data = pegel.attrib['onmouseover'].strip('pegelein(').strip(')').replace(",'", ",").split("',")
|
||||
gauge = Gauge(int(data[7]))
|
||||
gauge.name = data[0].strip("'")
|
||||
gauge.river = data[1]
|
||||
gauge.name = unicode(data[0].strip("'"))
|
||||
gauge.river = unicode(data[1])
|
||||
try:
|
||||
lastdate = date(*reversed([int(x) for x in data[2].split(' ')[0].split(".")]))
|
||||
lasttime = time(*[int(x) for x in data[2].split(' ')[1].split(":")])
|
||||
|
|
@ -49,11 +49,11 @@ class ListPage(BasePage):
|
|||
gauge.flow = NotAvailable
|
||||
bildforecast = data[5]
|
||||
if bildforecast == "pf_gerade.png":
|
||||
gauge.forecast = "stable"
|
||||
gauge.forecast = u"stable"
|
||||
elif bildforecast == "pf_unten.png":
|
||||
gauge.forecast = "Go down"
|
||||
gauge.forecast = u"Go down"
|
||||
elif bildforecast == "pf_oben.png":
|
||||
gauge.forecast = "Go up"
|
||||
gauge.forecast = u"Go up"
|
||||
else:
|
||||
gauge.forecast = NotAvailable
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue