PEP8 style fixes and other small style fixes

I used autopep8 on some files and did carefully check the changes.
I ignored E501,E302,E231,E225,E222,E221,E241,E203 in my search, and at
least E501 on any autopep8 run.

Other style fixes not related to PEP8:
* Only use new-style classes. I don't think the usage of old-style
  classes was voluntary. Old-style classes are removed in Python 3.
* Convert an if/else to a one-liner in mediawiki, change docstring style
  change to a comment something that wasn't really appropriate for a
  docstring.
* Unneeded first if condition in meteofrance
This commit is contained in:
Laurent Bachelier 2012-03-14 03:24:02 +01:00
commit 006e97a8be
99 changed files with 441 additions and 350 deletions

View file

@ -298,7 +298,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
yield thread.root yield thread.root
except BrowserUnavailable, e: except BrowserUnavailable, e:
self.logger.debug('No messages, browser is unavailable: %s' % e) self.logger.debug('No messages, browser is unavailable: %s' % e)
pass # don't care about waiting pass # don't care about waiting
def set_message_read(self, message): def set_message_read(self, message):
if message.id == self.MAGIC_ID_BASKET: if message.id == self.MAGIC_ID_BASKET:

View file

@ -24,7 +24,7 @@ import Image
class CaptchaError(Exception): pass class CaptchaError(Exception): pass
class Tile: class Tile(object):
hash = { hash = {
'bc8d52d96058478a6def26226145d53b': 'A', 'bc8d52d96058478a6def26226145d53b': 'A',
'c62ecdfddb72b2feaed96cd9fe7c2802': 'A', 'c62ecdfddb72b2feaed96cd9fe7c2802': 'A',
@ -111,7 +111,7 @@ class Tile:
print 'hash: %s' % checksum print 'hash: %s' % checksum
raise CaptchaError() raise CaptchaError()
class Captcha: class Captcha(object):
def __init__(self, f): def __init__(self, f):
self.img = Image.open(f) self.img = Image.open(f)
self.w, self.h = self.img.size self.w, self.h = self.img.size
@ -152,7 +152,7 @@ class Captcha:
s += tile.letter s += tile.letter
return s return s
class Decoder: class Decoder(object):
def __init__(self): def __init__(self):
self.hash = {} self.hash = {}

View file

@ -26,7 +26,8 @@ from weboob.tools.ordereddict import OrderedDict
from weboob.capabilities.contact import Contact as _Contact, ProfileNode from weboob.capabilities.contact import Contact as _Contact, ProfileNode
from weboob.tools.misc import html2text from weboob.tools.misc import html2text
class FieldBase:
class FieldBase(object):
def __init__(self, key, key2=None): def __init__(self, key, key2=None):
self.key = key self.key = key
self.key2 = key2 self.key2 = key2
@ -34,18 +35,22 @@ class FieldBase:
def get_value(self, value, consts): def get_value(self, value, consts):
raise NotImplementedError() raise NotImplementedError()
class FieldStr(FieldBase): class FieldStr(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
return html2text(unicode(profile[self.key])).strip() return html2text(unicode(profile[self.key])).strip()
class FieldBool(FieldBase): class FieldBool(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
return bool(int(profile[self.key])) return bool(int(profile[self.key]))
class FieldDist(FieldBase): class FieldDist(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
return '%.2f km' % float(profile[self.key]) return '%.2f km' % float(profile[self.key])
class FieldIP(FieldBase): class FieldIP(FieldBase):
def get_hostname(self, s): def get_hostname(self, s):
try: try:
@ -59,6 +64,7 @@ class FieldIP(FieldBase):
s += ' (first %s)' % self.get_hostname(profile[self.key2]) s += ' (first %s)' % self.get_hostname(profile[self.key2])
return s return s
class FieldProfileURL(FieldBase): class FieldProfileURL(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
id = int(profile[self.key]) id = int(profile[self.key])
@ -67,10 +73,12 @@ class FieldProfileURL(FieldBase):
else: else:
return '' return ''
class FieldPopu(FieldBase): class FieldPopu(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
return unicode(profile['popu'][self.key]) return unicode(profile['popu'][self.key])
class FieldPopuRatio(FieldBase): class FieldPopuRatio(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
v1 = float(profile['popu'][self.key]) v1 = float(profile['popu'][self.key])
@ -80,15 +88,18 @@ class FieldPopuRatio(FieldBase):
else: else:
return '%.2f' % (v1 / v2) return '%.2f' % (v1 / v2)
class FieldOld(FieldBase): class FieldOld(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
birthday = parse_dt(profile[self.key]) birthday = parse_dt(profile[self.key])
return int((datetime.now() - birthday).days / 365.25) return int((datetime.now() - birthday).days / 365.25)
class FieldSplit(FieldBase): class FieldSplit(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
return [html2text(s).strip() for s in profile[self.key].split(self.key2) if len(s.strip()) > 0] return [html2text(s).strip() for s in profile[self.key].split(self.key2) if len(s.strip()) > 0]
class FieldBMI(FieldBase): class FieldBMI(FieldBase):
def __init__(self, key, key2, fat=False): def __init__(self, key, key2, fat=False):
FieldBase.__init__(self, key, key2) FieldBase.__init__(self, key, key2)
@ -100,7 +111,7 @@ class FieldBMI(FieldBase):
if height == 0 or weight == 0: if height == 0 or weight == 0:
return '' return ''
bmi = (weight/float(pow(height/100.0, 2))) bmi = (weight / float(pow(height / 100.0, 2)))
if not self.fat: if not self.fat:
return bmi return bmi
elif bmi < 15.5: elif bmi < 15.5:
@ -114,6 +125,7 @@ class FieldBMI(FieldBase):
else: else:
return 'obese' return 'obese'
class FieldFlags(FieldBase): class FieldFlags(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
i = int(profile[self.key]) i = int(profile[self.key])
@ -123,6 +135,7 @@ class FieldFlags(FieldBase):
labels.append(html2text(d['label']).strip()) labels.append(html2text(d['label']).strip())
return labels return labels
class FieldList(FieldBase): class FieldList(FieldBase):
def get_value(self, profile, consts): def get_value(self, profile, consts):
i = int(profile[self.key]) i = int(profile[self.key])
@ -131,6 +144,7 @@ class FieldList(FieldBase):
return html2text(d['label']).strip() return html2text(d['label']).strip()
return '' return ''
class Contact(_Contact): class Contact(_Contact):
TABLE = OrderedDict(( TABLE = OrderedDict((
('_info', OrderedDict(( ('_info', OrderedDict((
@ -247,9 +261,9 @@ class Contact(_Contact):
if node.flags & node.SECTION: if node.flags & node.SECTION:
result += u'\t' * level + node.label + '\n' result += u'\t' * level + node.label + '\n'
for sub in node.value.itervalues(): for sub in node.value.itervalues():
result += print_node(sub, level+1) result += print_node(sub, level + 1)
else: else:
if isinstance(node.value, (tuple,list)): if isinstance(node.value, (tuple, list)):
value = ', '.join(unicode(v) for v in node.value) value = ', '.join(unicode(v) for v in node.value)
elif isinstance(node.value, float): elif isinstance(node.value, float):
value = '%.2f' % node.value value = '%.2f' % node.value

View file

@ -124,9 +124,9 @@ class PriorityConnection(Optimization):
browser = AuMBrowser('%s@%s' % (name, self.config['domain']), proxy=self.browser.proxy) browser = AuMBrowser('%s@%s' % (name, self.config['domain']), proxy=self.browser.proxy)
try: try:
browser.register(password= password, browser.register(password= password,
sex= 1, #slut sex= 1, # slut
birthday_d= random.randint(1,28), birthday_d= random.randint(1, 28),
birthday_m= random.randint(1,12), birthday_m= random.randint(1, 12),
birthday_y= random.randint(1975, 1990), birthday_y= random.randint(1975, 1990),
zipcode= 75001, zipcode= 75001,
country= 'fr', country= 'fr',

View file

@ -49,7 +49,7 @@ class ProfilesWalker(Optimization):
def start(self): def start(self):
self.walk_cron = self.sched.repeat(60, self.enqueue_profiles) self.walk_cron = self.sched.repeat(60, self.enqueue_profiles)
self.view_cron = self.sched.schedule(randint(10,40), self.view_profile) self.view_cron = self.sched.schedule(randint(10, 40), self.view_profile)
return True return True
def stop(self): def stop(self):
@ -77,7 +77,7 @@ class ProfilesWalker(Optimization):
try: try:
id = self.profiles_queue.pop() id = self.profiles_queue.pop()
except KeyError: except KeyError:
return # empty queue return # empty queue
try: try:
with self.browser: with self.browser:
@ -101,4 +101,4 @@ class ProfilesWalker(Optimization):
print e print e
finally: finally:
if self.view_cron is not None: if self.view_cron is not None:
self.view_cron = self.sched.schedule(randint(10,40), self.view_profile) self.view_cron = self.sched.schedule(randint(10, 40), self.view_profile)

View file

@ -22,7 +22,6 @@ from weboob.tools.test import BackendTest
from weboob.tools.browser import BrowserUnavailable from weboob.tools.browser import BrowserUnavailable
__all__ = ['AuMTest'] __all__ = ['AuMTest']

View file

@ -21,6 +21,7 @@ from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicRea
__all__ = ['BatotoBackend'] __all__ = ['BatotoBackend']
class BatotoBackend(GenericComicReaderBackend): class BatotoBackend(GenericComicReaderBackend):
NAME = 'batoto' NAME = 'batoto'
DESCRIPTION = 'Batoto manga reading website' DESCRIPTION = 'Batoto manga reading website'
@ -31,4 +32,4 @@ class BatotoBackend(GenericComicReaderBackend):
ID_REGEXP = r'[^/]+/[^/]+' ID_REGEXP = r'[^/]+/[^/]+'
URL_REGEXP = r'.+batoto.(?:com|net)/read/_/(%s).+' % ID_REGEXP URL_REGEXP = r'.+batoto.(?:com|net)/read/_/(%s).+' % ID_REGEXP
ID_TO_URL = 'http://www.batoto.net/read/_/%s' ID_TO_URL = 'http://www.batoto.net/read/_/%s'
PAGES = { URL_REGEXP: DisplayPage } PAGES = {URL_REGEXP: DisplayPage}

View file

@ -19,8 +19,9 @@
from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderTest from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderTest
class BatotoTest(GenericComicReaderTest): class BatotoTest(GenericComicReaderTest):
BACKEND = 'batoto' BACKEND = 'batoto'
def test_download(self): def test_download(self):
return self._test_download('26287/yurumates_ch4_by_primitive-scans') return self._test_download('26287/yurumates_ch4_by_primitive-scans')

View file

@ -70,4 +70,3 @@ class BoursoramaBackend(BaseBackend, ICapBank):
with self.browser: with self.browser:
for coming in self.browser.get_coming_operations(account): for coming in self.browser.get_coming_operations(account):
yield coming yield coming

View file

@ -32,7 +32,7 @@ __all__ = ['Boursorama']
class Boursorama(BaseBrowser): class Boursorama(BaseBrowser):
DOMAIN = 'www.boursorama.com' DOMAIN = 'www.boursorama.com'
PROTOCOL = 'https' PROTOCOL = 'https'
ENCODING = None # refer to the HTML encoding ENCODING = None # refer to the HTML encoding
PAGES = { PAGES = {
'.*connexion.phtml.*': LoginPage, '.*connexion.phtml.*': LoginPage,
'.*/comptes/synthese.phtml': AccountsList, '.*/comptes/synthese.phtml': AccountsList,
@ -84,11 +84,11 @@ class Boursorama(BaseBrowser):
self.location(account._link_id) self.location(account._link_id)
operations = self.page.get_operations() operations = self.page.get_operations()
# load last month as well # load last month as well
target = date.today() - relativedelta( months = 1 ) target = date.today() - relativedelta(months=1)
self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year))) self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year)))
operations += self.page.get_operations() operations += self.page.get_operations()
# and the month before, just in case you're greedy # and the month before, just in case you're greedy
target = date.today() - relativedelta( months = 2 ) target = date.today() - relativedelta(months=2)
self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year))) self.location(account._link_id + ("&month=%d&year=%d" % (target.month, target.year)))
operations += self.page.get_operations() operations += self.page.get_operations()
for index, op in enumerate(operations): for index, op in enumerate(operations):

View file

@ -23,7 +23,8 @@ from .account_history import AccountHistory
from .accounts_list import AccountsList from .accounts_list import AccountsList
from .login import LoginPage from .login import LoginPage
class AccountPrelevement(AccountsList): pass class AccountPrelevement(AccountsList):
pass
__all__ = ['LoginPage', __all__ = ['LoginPage',
'AccountsList', 'AccountsList',

View file

@ -22,8 +22,8 @@
from weboob.capabilities.bank import Account from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage from weboob.tools.browser import BasePage
class AccountsList(BasePage):
class AccountsList(BasePage):
def on_loaded(self): def on_loaded(self):
pass pass
@ -34,34 +34,34 @@ class AccountsList(BasePage):
for tr in div.getiterator('tr'): for tr in div.getiterator('tr'):
account = Account() account = Account()
for td in tr.getiterator('td'): for td in tr.getiterator('td'):
if td.attrib.get('class', '') == 'account-cb': if td.attrib.get('class', '') == 'account-cb':
break break
elif td.attrib.get('class', '') == 'account-name': elif td.attrib.get('class', '') == 'account-name':
a = td.find('a') a = td.find('a')
account.label = a.text account.label = a.text
account._link_id = a.get('href', '') account._link_id = a.get('href', '')
elif td.attrib.get('class', '') == 'account-number': elif td.attrib.get('class', '') == 'account-number':
id = td.text id = td.text
id = id.strip(u' \n\t') id = id.strip(u' \n\t')
account.id = id account.id = id
elif td.attrib.get('class', '') == 'account-total': elif td.attrib.get('class', '') == 'account-total':
span = td.find('span') span = td.find('span')
if span == None: if span == None:
balance = td.text balance = td.text
else: else:
balance = span.text balance = span.text
balance = balance.strip(u' \n\t€+').replace(',','.').replace(' ','') balance = balance.strip(u' \n\t€+').replace(',', '.').replace(' ', '')
if balance != "": if balance != "":
account.balance = float(balance) account.balance = float(balance)
else: else:
account.balance = 0.0 account.balance = 0.0
else: else:
# because of some weird useless <tr> # because of some weird useless <tr>
if account.id != 0: if account.id != 0:
l.append(account) l.append(account)
return l return l

View file

@ -26,7 +26,7 @@ __all__ = ['LoginPage']
class LoginPage(BasePage): class LoginPage(BasePage):
def on_loaded(self): def on_loaded(self):
pass pass
# for td in self.document.getroot().cssselect('td.LibelleErreur'): # for td in self.document.getroot().cssselect('td.LibelleErreur'):
# if td.text is None: # if td.text is None:
# continue # continue

View file

@ -35,7 +35,7 @@ __all__ = ['BPBrowser']
class BPBrowser(BaseBrowser): class BPBrowser(BaseBrowser):
DOMAIN = 'voscomptesenligne.labanquepostale.fr' DOMAIN = 'voscomptesenligne.labanquepostale.fr'
PROTOCOL = 'https' PROTOCOL = 'https'
ENCODING = None # refer to the HTML encoding ENCODING = None # refer to the HTML encoding
PAGES = {r'.*wsost/OstBrokerWeb/loginform.*' : LoginPage, PAGES = {r'.*wsost/OstBrokerWeb/loginform.*' : LoginPage,
r'.*authentification/repositionnerCheminCourant-identif.ea' : repositionnerCheminCourant, r'.*authentification/repositionnerCheminCourant-identif.ea' : repositionnerCheminCourant,
r'.*authentification/initialiser-identif.ea' : Initident, r'.*authentification/initialiser-identif.ea' : Initident,

View file

@ -54,7 +54,7 @@ class AccountHistory(BasePage):
for t in tmp: for t in tmp:
if r.search(t.text): if r.search(t.text):
amount = t.text amount = t.text
amount = ''.join( amount.replace('.', '').replace(',', '.').split() ) amount = ''.join(amount.replace('.', '').replace(',', '.').split())
if amount[0] == "-": if amount[0] == "-":
operation.amount = -float(amount[1:]) operation.amount = -float(amount[1:])
else: else:

View file

@ -26,6 +26,7 @@ __all__ = ['CanalplusVideo']
class CanalplusVideo(BaseVideo): class CanalplusVideo(BaseVideo):
swf_player = False swf_player = False
@classmethod @classmethod
def id2url(cls, _id): def id2url(cls, _id):
return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id

View file

@ -33,8 +33,10 @@ from lxml import etree
from datetime import date from datetime import date
from StringIO import StringIO from StringIO import StringIO
__all__ = ['CmbBackend'] __all__ = ['CmbBackend']
class CmbBackend(BaseBackend, ICapBank): class CmbBackend(BaseBackend, ICapBank):
NAME = 'cmb' NAME = 'cmb'
MAINTAINER = 'Johann Broudin' MAINTAINER = 'Johann Broudin'
@ -83,7 +85,6 @@ class CmbBackend(BaseBackend, ICapBank):
) )
] ]
cookie = None cookie = None
headers = { headers = {
'User-Agent': 'User-Agent':
@ -167,13 +168,13 @@ class CmbBackend(BaseBackend, ICapBank):
balance = td[1].text balance = td[1].text
balance = balance.replace(',','.').replace(u"\xa0",'') balance = balance.replace(',', '.').replace(u"\xa0", '')
account.balance = float(balance) account.balance = float(balance)
span = td[3].xpath('a/span') span = td[3].xpath('a/span')
if len(span): if len(span):
coming = span[0].text.replace(' ','').replace(',','.') coming = span[0].text.replace(' ', '').replace(',', '.')
coming = coming.replace(u"\xa0",'') coming = coming.replace(u"\xa0", '')
account.coming = float(coming) account.coming = float(coming)
else: else:
account.coming = NotAvailable account.coming = NotAvailable
@ -248,7 +249,7 @@ class CmbBackend(BaseBackend, ICapBank):
operation.date = date(*reversed([int(x) for x in d])) operation.date = date(*reversed([int(x) for x in d]))
div = td[2].xpath('div') div = td[2].xpath('div')
label = div[0].xpath('a')[0].text.replace('\n','') label = div[0].xpath('a')[0].text.replace('\n', '')
operation.raw = unicode(' '.join(label.split())) operation.raw = unicode(' '.join(label.split()))
for pattern, _type, _label in self.LABEL_PATTERNS: for pattern, _type, _label in self.LABEL_PATTERNS:
mm = pattern.match(operation.raw) mm = pattern.match(operation.raw)
@ -260,12 +261,11 @@ class CmbBackend(BaseBackend, ICapBank):
amount = td[3].text amount = td[3].text
if amount.count(',') != 1: if amount.count(',') != 1:
amount = td[4].text amount = td[4].text
amount = amount.replace(',','.').replace(u'\xa0','') amount = amount.replace(',', '.').replace(u'\xa0', '')
operation.amount = float(amount) operation.amount = float(amount)
else: else:
amount = amount.replace(',','.').replace(u'\xa0','') amount = amount.replace(',', '.').replace(u'\xa0', '')
operation.amount = - float(amount) operation.amount = - float(amount)
i += 1 i += 1
yield operation yield operation

View file

@ -24,6 +24,7 @@ from weboob.capabilities.bank import Account
from .base import CragrBasePage from .base import CragrBasePage
from weboob.capabilities.bank import Transaction from weboob.capabilities.bank import Transaction
def clean_amount(amount): def clean_amount(amount):
""" """
Removes weird characters and converts to a float Removes weird characters and converts to a float
@ -34,6 +35,7 @@ def clean_amount(amount):
matches = re.findall('^(-?[0-9]+\.[0-9]{2}).*$', data) matches = re.findall('^(-?[0-9]+\.[0-9]{2}).*$', data)
return float(matches[0]) if (matches) else 0.0 return float(matches[0]) if (matches) else 0.0
class AccountsList(CragrBasePage): class AccountsList(CragrBasePage):
def get_list(self): def get_list(self):
@ -109,7 +111,7 @@ class AccountsList(CragrBasePage):
select_name is the name of the select field to analyze select_name is the name of the select field to analyze
""" """
if not self.is_transfer_page(): if not self.is_transfer_page():
return False return False
source_accounts = {} source_accounts = {}
source_account_options = self.document.xpath('/html/body//form//select[@name="%s"]/option' % select_name) source_account_options = self.document.xpath('/html/body//form//select[@name="%s"]/option' % select_name)
for option in source_account_options: for option in source_account_options:
@ -212,7 +214,7 @@ class AccountsList(CragrBasePage):
year = today.year year = today.year
return date(year, month, day) return date(year, month, day)
def get_history(self, start_index = 0, start_offset = 0): def get_history(self, start_index=0, start_offset=0):
""" """
Returns the history of a specific account. Note that this function Returns the history of a specific account. Note that this function
expects the current page to be the one dedicated to this history. expects the current page to be the one dedicated to this history.

View file

@ -26,6 +26,7 @@ from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, Opera
__all__ = ['CreditMutuelBrowser'] __all__ = ['CreditMutuelBrowser']
# Browser # Browser
class CreditMutuelBrowser(BaseBrowser): class CreditMutuelBrowser(BaseBrowser):
PROTOCOL = 'https' PROTOCOL = 'https'
@ -36,11 +37,11 @@ class CreditMutuelBrowser(BaseBrowser):
'https://www.creditmutuel.fr/groupe/fr/identification/default.cgi': LoginErrorPage, 'https://www.creditmutuel.fr/groupe/fr/identification/default.cgi': LoginErrorPage,
'https://www.creditmutuel.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage, 'https://www.creditmutuel.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage,
'https://www.creditmutuel.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage, 'https://www.creditmutuel.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage,
'https://www.creditmutuel.fr/.*/fr/banque/mouvements.cgi.*' : OperationsPage, 'https://www.creditmutuel.fr/.*/fr/banque/mouvements.cgi.*': OperationsPage,
'https://www.creditmutuel.fr/.*/fr/banque/nr/nr_devbooster.aspx.*' : OperationsPage, 'https://www.creditmutuel.fr/.*/fr/banque/nr/nr_devbooster.aspx.*': OperationsPage,
'https://www.creditmutuel.fr/.*/fr/banque/operations_carte\.cgi.*' : OperationsPage, 'https://www.creditmutuel.fr/.*/fr/banque/operations_carte\.cgi.*': OperationsPage,
'https://www.creditmutuel.fr/.*/fr/banque/BAD.*' : InfoPage, 'https://www.creditmutuel.fr/.*/fr/banque/BAD.*': InfoPage,
'https://www.creditmutuel.fr/.*/fr/banque/.*Vir.*' : TransfertPage 'https://www.creditmutuel.fr/.*/fr/banque/.*Vir.*': TransfertPage
} }
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -61,17 +62,17 @@ class CreditMutuelBrowser(BaseBrowser):
if not self.is_on_page(LoginPage): if not self.is_on_page(LoginPage):
self.location('https://www.creditmutuel.fr/', no_login=True) self.location('https://www.creditmutuel.fr/', no_login=True)
self.page.login( self.username, self.password) self.page.login(self.username, self.password)
if not self.is_logged() or self.is_on_page(LoginErrorPage): if not self.is_logged() or self.is_on_page(LoginErrorPage):
raise BrowserIncorrectPassword() raise BrowserIncorrectPassword()
self.SUB_BANKS = ['cmdv','cmcee','cmse', 'cmidf', 'cmsmb', 'cmma', 'cmmabn', 'cmc', 'cmlaco', 'cmnormandie', 'cmm'] self.SUB_BANKS = ['cmdv', 'cmcee', 'cmse', 'cmidf', 'cmsmb', 'cmma', 'cmmabn', 'cmc', 'cmlaco', 'cmnormandie', 'cmm']
self.getCurrentSubBank() self.getCurrentSubBank()
def get_accounts_list(self): def get_accounts_list(self):
if not self.is_on_page(AccountsPage): if not self.is_on_page(AccountsPage):
self.location('https://www.creditmutuel.fr/%s/fr/banque/situation_financiere.cgi'%self.currentSubBank) self.location('https://www.creditmutuel.fr/%s/fr/banque/situation_financiere.cgi' % self.currentSubBank)
return self.page.get_list() return self.page.get_list()
def get_account(self, id): def get_account(self, id):
@ -121,13 +122,13 @@ class CreditMutuelBrowser(BaseBrowser):
def transfer(self, account, to, amount, reason=None): def transfer(self, account, to, amount, reason=None):
# access the transfer page # access the transfer page
transfert_url = 'WI_VPLV_VirUniSaiCpt.asp?RAZ=ALL&Cat=6&PERM=N&CHX=A' transfert_url = 'WI_VPLV_VirUniSaiCpt.asp?RAZ=ALL&Cat=6&PERM=N&CHX=A'
self.location('https://%s/%s/fr/banque/%s'%(self.DOMAIN, self.currentSubBank, transfert_url)) self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, transfert_url))
# fill the form # fill the form
self.select_form(name='FormVirUniSaiCpt') self.select_form(name='FormVirUniSaiCpt')
self['IDB'] = [account[-1]] self['IDB'] = [account[-1]]
self['ICR'] = [to[-1]] self['ICR'] = [to[-1]]
self['MTTVIR'] = '%s' % str(amount).replace('.',',') self['MTTVIR'] = '%s' % str(amount).replace('.', ',')
if reason != None: if reason != None:
self['LIBDBT'] = reason self['LIBDBT'] = reason
self['LIBCRT'] = reason self['LIBCRT'] = reason

View file

@ -27,7 +27,7 @@ from ..tools import url2id
from .index import DLFPPage from .index import DLFPPage
class RSSComment(DLFPPage): class RSSComment(DLFPPage):
def on_loaded(self): def on_loaded(self):
pass pass
class Content(object): class Content(object):

Some files were not shown because too many files have changed in this diff Show more