Use strings instead of integers internally for account IDs
This commit is contained in:
parent
7d0105c167
commit
024f217c8b
7 changed files with 24 additions and 33 deletions
|
|
@ -65,17 +65,14 @@ class BNPorcBackend(BaseBackend, ICapBank):
|
|||
yield account
|
||||
|
||||
def get_account(self, _id):
|
||||
try:
|
||||
_id = long(_id)
|
||||
except ValueError:
|
||||
if not _id.isdigit():
|
||||
raise AccountNotFound()
|
||||
with self.browser:
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
with self.browser:
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
raise AccountNotFound()
|
||||
raise AccountNotFound()
|
||||
|
||||
def iter_history(self, account):
|
||||
with self.browser:
|
||||
|
|
@ -92,10 +89,10 @@ class BNPorcBackend(BaseBackend, ICapBank):
|
|||
account = account.id
|
||||
|
||||
try:
|
||||
account = long(account)
|
||||
to = long(to)
|
||||
assert account.isdigit()
|
||||
assert to.isdigit()
|
||||
amount = float(amount)
|
||||
except ValueError:
|
||||
except (AssertionError, ValueError):
|
||||
raise AccountNotFound()
|
||||
|
||||
with self.browser:
|
||||
|
|
|
|||
|
|
@ -104,14 +104,14 @@ class BNPorc(BaseBrowser):
|
|||
return self.page.get_list()
|
||||
|
||||
def get_account(self, id):
|
||||
assert isinstance(id, (int, long))
|
||||
assert isinstance(id, (str, unicode))
|
||||
|
||||
if not self.is_on_page(pages.AccountsList):
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||
|
||||
l = self.page.get_list()
|
||||
for a in l:
|
||||
if long(a.id) == id:
|
||||
if a.id == id:
|
||||
return a
|
||||
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TransferPage(BasePage):
|
|||
if table.attrib.get('cellspacing') == '2':
|
||||
for tr in table.cssselect('tr.hdoc1, tr.hdotc1'):
|
||||
tds = tr.findall('td')
|
||||
id = long(tds[1].text.replace(u'\xa0', u''))
|
||||
id = tds[1].text.replace(u'\xa0', u'')
|
||||
if id == from_id:
|
||||
if tds[4].find('input') is None:
|
||||
raise TransferError("Unable to make a transfer from %s" % from_id)
|
||||
|
|
|
|||
|
|
@ -46,16 +46,13 @@ class CragrBackend(BaseBackend, ICapBank):
|
|||
yield account
|
||||
|
||||
def get_account(self, _id):
|
||||
try:
|
||||
_id = long(_id)
|
||||
except ValueError:
|
||||
if not _id.isdigit():
|
||||
raise AccountNotFound()
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
raise AccountNotFound()
|
||||
raise AccountNotFound()
|
||||
|
||||
def iter_operations(self, account):
|
||||
""" TODO Not supported yet """
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Cragr(BaseBrowser):
|
|||
return self.page.get_list()
|
||||
|
||||
def get_account(self, id):
|
||||
assert isinstance(id, (int, long))
|
||||
assert isinstance(id, (str, unicode))
|
||||
|
||||
l = self.get_accounts_list()
|
||||
for a in l:
|
||||
|
|
|
|||
|
|
@ -46,16 +46,13 @@ class LCLBackend(BaseBackend, ICapBank):
|
|||
yield account
|
||||
|
||||
def get_account(self, _id):
|
||||
try:
|
||||
_id = long(_id)
|
||||
except ValueError:
|
||||
if not _id.isdigit():
|
||||
raise AccountNotFound()
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
account = self.browser.get_account(_id)
|
||||
if account:
|
||||
return account
|
||||
else:
|
||||
raise AccountNotFound()
|
||||
raise AccountNotFound()
|
||||
|
||||
def iter_operations(self, account):
|
||||
""" TODO Not supported yet """
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class LCLBrowser(BaseBrowser):
|
|||
return self.page.get_list()
|
||||
|
||||
def get_account(self, id):
|
||||
assert isinstance(id, (int, long))
|
||||
assert isinstance(id, (str, unicode))
|
||||
|
||||
l = self.get_accounts_list()
|
||||
for a in l:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue