pyflakes/pep8 cleaning
This commit is contained in:
parent
1fd0cb1291
commit
2a7f373168
3 changed files with 13 additions and 8 deletions
|
|
@ -90,4 +90,4 @@ class AmeliProBackend(BaseBackend, ICapBill):
|
||||||
if not isinstance(bill, Bill):
|
if not isinstance(bill, Bill):
|
||||||
bill = self.get_bill(bill)
|
bill = self.get_bill(bill)
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.readurl(bill._url,urllib.urlencode(bill._args))
|
return self.browser.readurl(bill._url, urllib.urlencode(bill._args))
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import mechanize
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from weboob.tools.browser import BaseBrowser
|
|
||||||
from weboob.capabilities.bill import Detail
|
from weboob.capabilities.bill import Detail
|
||||||
from decimal import *
|
from decimal import Decimal
|
||||||
from .pages import LoginPage, HomePage, AccountPage, HistoryPage, BillsPage
|
from .pages import LoginPage, HomePage, AccountPage, HistoryPage, BillsPage
|
||||||
|
|
||||||
__all__ = ['AmeliProBrowser']
|
__all__ = ['AmeliProBrowser']
|
||||||
|
|
||||||
|
|
||||||
class AmeliProBrowser(BaseBrowser):
|
class AmeliProBrowser(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
DOMAIN = 'espacepro.ameli.fr'
|
DOMAIN = 'espacepro.ameli.fr'
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.bill import Subscription, Detail, Bill
|
from weboob.capabilities.bill import Subscription, Detail, Bill
|
||||||
|
|
||||||
|
|
@ -30,6 +31,7 @@ __all__ = ['LoginPage', 'HomePage', 'AccountPage', 'HistoryPage', 'BillsPage']
|
||||||
# Ugly array to avoid the use of french locale
|
# Ugly array to avoid the use of french locale
|
||||||
FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
|
FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre']
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(BasePage):
|
class LoginPage(BasePage):
|
||||||
def login(self, login, password):
|
def login(self, login, password):
|
||||||
self.browser.select_form('connexionCompteForm')
|
self.browser.select_form('connexionCompteForm')
|
||||||
|
|
@ -37,6 +39,7 @@ class LoginPage(BasePage):
|
||||||
self.browser["vp_connexion_portlet_1password"] = password.encode('utf8')
|
self.browser["vp_connexion_portlet_1password"] = password.encode('utf8')
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
||||||
|
|
||||||
class HomePage(BasePage):
|
class HomePage(BasePage):
|
||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
|
|
@ -57,6 +60,7 @@ class AccountPage(BasePage):
|
||||||
sub.subscriber = unicode(name)
|
sub.subscriber = unicode(name)
|
||||||
return sub
|
return sub
|
||||||
|
|
||||||
|
|
||||||
class HistoryPage(BasePage):
|
class HistoryPage(BasePage):
|
||||||
|
|
||||||
def iter_history(self):
|
def iter_history(self):
|
||||||
|
|
@ -77,9 +81,10 @@ class HistoryPage(BasePage):
|
||||||
det.label = lot
|
det.label = lot
|
||||||
det.infos = factures_lbl
|
det.infos = factures_lbl
|
||||||
det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
|
det.datetime = datetime.strptime(date, "%d/%m/%Y").date()
|
||||||
det.price = Decimal(montant.replace(',','.'))
|
det.price = Decimal(montant.replace(',', '.'))
|
||||||
yield det
|
yield det
|
||||||
|
|
||||||
|
|
||||||
class BillsPage(BasePage):
|
class BillsPage(BasePage):
|
||||||
|
|
||||||
def iter_bills(self):
|
def iter_bills(self):
|
||||||
|
|
@ -91,7 +96,7 @@ class BillsPage(BasePage):
|
||||||
|
|
||||||
date_str = tr.xpath('.//td[@class="cAlignGauche"]')[0].text
|
date_str = tr.xpath('.//td[@class="cAlignGauche"]')[0].text
|
||||||
month_str = date_str.split()[0]
|
month_str = date_str.split()[0]
|
||||||
date = datetime.strptime(re.sub(month_str,str(FRENCH_MONTHS.index(month_str) + 1),date_str),"%m %Y").date()
|
date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date()
|
||||||
amount = tr.xpath('.//td[@class="cAlignDroite"]')[0].text
|
amount = tr.xpath('.//td[@class="cAlignDroite"]')[0].text
|
||||||
for format in ('CSV', 'PDF'):
|
for format in ('CSV', 'PDF'):
|
||||||
bil = Bill()
|
bil = Bill()
|
||||||
|
|
@ -107,5 +112,5 @@ class BillsPage(BasePage):
|
||||||
}
|
}
|
||||||
yield bil
|
yield bil
|
||||||
|
|
||||||
def get_bill(self,bill):
|
def get_bill(self, bill):
|
||||||
self.location(bill._url, urllib.urlencode(bill._args))
|
self.location(bill._url, urllib.urlencode(bill._args))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue