Fix obvious pep8 errors
This commit is contained in:
parent
2a7f373168
commit
a155337b4f
3 changed files with 18 additions and 16 deletions
|
|
@ -88,4 +88,4 @@ class AmeliBackend(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))
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from .pages import LoginPage, HomePage, AccountPage, LastPaymentsPage, PaymentDe
|
||||||
|
|
||||||
__all__ = ['AmeliBrowser']
|
__all__ = ['AmeliBrowser']
|
||||||
|
|
||||||
|
|
||||||
class AmeliBrowser(BaseBrowser):
|
class AmeliBrowser(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
DOMAIN = 'assure.ameli.fr'
|
DOMAIN = 'assure.ameli.fr'
|
||||||
|
|
@ -34,7 +35,7 @@ class AmeliBrowser(BaseBrowser):
|
||||||
'.*_pageLabel=as_etat_civil_page.*': AccountPage,
|
'.*_pageLabel=as_etat_civil_page.*': AccountPage,
|
||||||
'.*_pageLabel=as_revele_mensuel_presta_page.*': BillsPage,
|
'.*_pageLabel=as_revele_mensuel_presta_page.*': BillsPage,
|
||||||
'.*_pageLabel=as_dernier_paiement_page': LastPaymentsPage,
|
'.*_pageLabel=as_dernier_paiement_page': LastPaymentsPage,
|
||||||
'.*_actionOverride=%2Fportlets%2Fpaiements%2Fdetailpaiements&paiements.*' : PaymentDetailsPage
|
'.*_actionOverride=%2Fportlets%2Fpaiements%2Fdetailpaiements&paiements.*': PaymentDetailsPage
|
||||||
}
|
}
|
||||||
|
|
||||||
loginp = '/PortailAS/appmanager/PortailAS/assure?_somtc=true&_pageLabel=as_login_page'
|
loginp = '/PortailAS/appmanager/PortailAS/assure?_somtc=true&_pageLabel=as_login_page'
|
||||||
|
|
@ -80,7 +81,7 @@ class AmeliBrowser(BaseBrowser):
|
||||||
assert isinstance(id, basestring)
|
assert isinstance(id, basestring)
|
||||||
for sub in self.iter_subscription_list():
|
for sub in self.iter_subscription_list():
|
||||||
if id == sub._id:
|
if id == sub._id:
|
||||||
return sub
|
return sub
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def iter_history(self, sub):
|
def iter_history(self, sub):
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,12 @@ __all__ = ['AmeliBasePage', 'LoginPage', 'HomePage', 'AccountPage', 'LastPayment
|
||||||
# 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 AmeliBasePage(BasePage):
|
class AmeliBasePage(BasePage):
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
return len(self.document.xpath('//a[@id="logout"]')) > 0
|
return len(self.document.xpath('//a[@id="logout"]')) > 0
|
||||||
|
|
||||||
|
|
||||||
class LoginPage(AmeliBasePage):
|
class LoginPage(AmeliBasePage):
|
||||||
def login(self, login, password):
|
def login(self, login, password):
|
||||||
self.browser.select_form('connexionCompteForm')
|
self.browser.select_form('connexionCompteForm')
|
||||||
|
|
@ -42,8 +44,8 @@ class LoginPage(AmeliBasePage):
|
||||||
self.browser["connexioncompte_2codeConfidentiel"] = password.encode('utf8')
|
self.browser["connexioncompte_2codeConfidentiel"] = password.encode('utf8')
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
||||||
class HomePage(AmeliBasePage):
|
|
||||||
|
|
||||||
|
class HomePage(AmeliBasePage):
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -70,8 +72,8 @@ class AccountPage(AmeliBasePage):
|
||||||
sub.subscriber = unicode(name)
|
sub.subscriber = unicode(name)
|
||||||
yield sub
|
yield sub
|
||||||
|
|
||||||
class LastPaymentsPage(AmeliBasePage):
|
|
||||||
|
|
||||||
|
class LastPaymentsPage(AmeliBasePage):
|
||||||
def iter_last_payments(self):
|
def iter_last_payments(self):
|
||||||
list_table = self.document.xpath('//table[@id="ligneTabDerniersPaiements"]')
|
list_table = self.document.xpath('//table[@id="ligneTabDerniersPaiements"]')
|
||||||
if len(list_table) > 0:
|
if len(list_table) > 0:
|
||||||
|
|
@ -82,13 +84,13 @@ class LastPaymentsPage(AmeliBasePage):
|
||||||
continue
|
continue
|
||||||
yield list_a[0].attrib.get('href')
|
yield list_a[0].attrib.get('href')
|
||||||
|
|
||||||
class PaymentDetailsPage(AmeliBasePage):
|
|
||||||
|
|
||||||
|
class PaymentDetailsPage(AmeliBasePage):
|
||||||
def iter_payment_details(self, sub):
|
def iter_payment_details(self, sub):
|
||||||
if sub._id.isdigit():
|
if sub._id.isdigit():
|
||||||
idx = 0
|
idx = 0
|
||||||
else:
|
else:
|
||||||
idx = sub._id.replace('AFFILIE','')
|
idx = sub._id.replace('AFFILIE', '')
|
||||||
if len(self.document.xpath('//div[@class="centrepage"]/h3')) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
|
if len(self.document.xpath('//div[@class="centrepage"]/h3')) > idx or self.document.xpath('//table[@id="DetailPaiement3"]') > idx:
|
||||||
id_str = self.document.xpath('//div[@class="centrepage"]/h3')[idx].text.strip()
|
id_str = self.document.xpath('//div[@class="centrepage"]/h3')[idx].text.strip()
|
||||||
m = re.match('.*le (.*) pour un montant de.*', id_str)
|
m = re.match('.*le (.*) pour un montant de.*', id_str)
|
||||||
|
|
@ -100,7 +102,7 @@ class PaymentDetailsPage(AmeliBasePage):
|
||||||
line = 1
|
line = 1
|
||||||
last_date = None
|
last_date = None
|
||||||
for tr in table:
|
for tr in table:
|
||||||
tds = tr.xpath('.//td');
|
tds = tr.xpath('.//td')
|
||||||
if len(tds) == 0:
|
if len(tds) == 0:
|
||||||
continue
|
continue
|
||||||
date_str = tds[0].text
|
date_str = tds[0].text
|
||||||
|
|
@ -114,13 +116,13 @@ class PaymentDetailsPage(AmeliBasePage):
|
||||||
det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', tds[2].text)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', tds[3].text)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', tds[4].text)) + '%'
|
det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', tds[2].text)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', tds[3].text)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', tds[4].text)) + '%'
|
||||||
det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
|
det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date()
|
||||||
last_date = det.datetime
|
last_date = det.datetime
|
||||||
det.price = Decimal(re.sub('[^\d,-]+', '', tds[5].text).replace(',','.'))
|
det.price = Decimal(re.sub('[^\d,-]+', '', tds[5].text).replace(',', '.'))
|
||||||
line = line + 1
|
line = line + 1
|
||||||
yield det
|
yield det
|
||||||
|
|
||||||
class BillsPage(AmeliBasePage):
|
|
||||||
|
|
||||||
def iter_bills(self,sub):
|
class BillsPage(AmeliBasePage):
|
||||||
|
def iter_bills(self, sub):
|
||||||
table = self.document.xpath('//table[@id="tableauDecompte"]')[0].xpath('.//tr')
|
table = self.document.xpath('//table[@id="tableauDecompte"]')[0].xpath('.//tr')
|
||||||
for tr in table:
|
for tr in table:
|
||||||
list_tds = tr.xpath('.//td')
|
list_tds = tr.xpath('.//td')
|
||||||
|
|
@ -128,11 +130,11 @@ class BillsPage(AmeliBasePage):
|
||||||
continue
|
continue
|
||||||
date_str = list_tds[0].text
|
date_str = list_tds[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 = list_tds[1].text
|
amount = list_tds[1].text
|
||||||
if amount is None:
|
if amount is None:
|
||||||
continue
|
continue
|
||||||
amount = re.sub(' euros','',amount)
|
amount = re.sub(' euros', '', amount)
|
||||||
bil = Bill()
|
bil = Bill()
|
||||||
bil.id = sub._id + "." + date.strftime("%Y%m")
|
bil.id = sub._id + "." + date.strftime("%Y%m")
|
||||||
bil.date = date
|
bil.date = date
|
||||||
|
|
@ -143,6 +145,5 @@ class BillsPage(AmeliBasePage):
|
||||||
bil._args = {'PDF.moisRecherche': filedate}
|
bil._args = {'PDF.moisRecherche': filedate}
|
||||||
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