From 8165a91ff367228dd4a95f968562bbf4af96c2d8 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 10 Jan 2013 15:17:59 +0100 Subject: [PATCH] Pep8 cleaning --- modules/sachsen/backend.py | 6 ++++-- modules/sachsen/browser.py | 9 ++++++--- modules/sachsen/pages.py | 24 +++++++++++++++--------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/modules/sachsen/backend.py b/modules/sachsen/backend.py index 14fb083174..4179736da9 100644 --- a/modules/sachsen/backend.py +++ b/modules/sachsen/backend.py @@ -21,7 +21,8 @@ from __future__ import with_statement from .browser import SachsenBrowser -from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge, SensorNotFound +from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge,\ + SensorNotFound from weboob.tools.backend import BaseBackend @@ -44,7 +45,8 @@ def iter_gauges(self, pattern=None): else: lowpattern = pattern.lower() for gauge in self.browser.get_rivers_list(): - if lowpattern in gauge.name.lower() or lowpattern in gauge.object.lower(): + if lowpattern in gauge.name.lower()\ + or lowpattern in gauge.object.lower(): yield gauge def _get_gauge_by_id(self, id): diff --git a/modules/sachsen/browser.py b/modules/sachsen/browser.py index c858575115..11f598702e 100644 --- a/modules/sachsen/browser.py +++ b/modules/sachsen/browser.py @@ -34,17 +34,20 @@ class SachsenBrowser(BaseBrowser): '.*hwz/MP/.*': HistoryPage } + homepage = '/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html' + def __init__(self, *args, **kwargs): BaseBrowser.__init__(self, *args, **kwargs) def home(self): - self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html') + self.location(self.homepage) def get_rivers_list(self): if not self.is_on_page(ListPage): - self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/inhalt_re.html') + self.location(self.homepage) return self.page.get_rivers_list() def iter_history(self, sensor): - self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/MP/%d/index.html' % int(sensor.gaugeid)) + self.location('/de/wu/umwelt/lfug/lfug-internet/hwz/MP/%d/index.html' + % int(sensor.gaugeid)) return self.page.iter_history(sensor) diff --git a/modules/sachsen/pages.py b/modules/sachsen/pages.py index 55a8e3e85e..dd7b028830 100644 --- a/modules/sachsen/pages.py +++ b/modules/sachsen/pages.py @@ -27,24 +27,28 @@ class ListPage(BasePage): - alarmlevel = {"as1.gif": u"Alarmstufe 1", "as2.gif": u"Alarmstufe 2", \ - "as3.gif": u"Alarmstufe 3", "as4.gig": u"Alarmstufe 4", \ - "qua_grau.gif": u"No alarm function", "p_gruen.gif": u"", \ + alarmlevel = {"as1.gif": u"Alarmstufe 1", "as2.gif": u"Alarmstufe 2", + "as3.gif": u"Alarmstufe 3", "as4.gig": u"Alarmstufe 4", + "qua_grau.gif": u"No alarm function", "p_gruen.gif": u"", "qua_weiss.gif": u"no data"} + def get_rivers_list(self): for pegel in self.document.getroot().xpath(".//a[@onmouseout='pegelaus()']"): div = pegel.getparent() img = div.find('.//img').attrib['src'].split('/')[1] - data = pegel.attrib['onmouseover'].strip('pegelein(').strip(')').replace(",'", ",").split("',") + data = pegel.attrib['onmouseover']\ + .strip('pegelein(').strip(')').replace(",'", ",").split("',") gauge = Gauge(int(data[7])) gauge.name = unicode(data[0].strip("'")) - gauge.city = gauge.name.split(' ')[0] # TODO: real regexp to remove the number + gauge.city = gauge.name.split(' ')[0] gauge.object = unicode(data[1]) sensors = [] 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(":")]) + 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(":")]) lastdate = datetime.combine(lastdate, lasttime) except: lastdate = NotAvailable @@ -106,8 +110,10 @@ def iter_history(self, sensor): lines.pop(0) # remove first value (already in lastvalue) for line in lines: history = GaugeMeasure() - leveldate = date(*reversed([int(x) for x in line[0].text_content().split(' ')[0].split(".")])) - leveltime = time(*[int(x) for x in line[0].text_content().split(' ')[1].split(":")]) + leveldate = date(*reversed([int(x) + for x in line[0].text_content().split(' ')[0].split(".")])) + leveltime = time(*[int(x) + for x in line[0].text_content().split(' ')[1].split(":")]) history.date = datetime.combine(leveldate, leveltime) if sensor.name == u"Level": -- GitLab