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
|
yield account
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
try:
|
if not _id.isdigit():
|
||||||
_id = long(_id)
|
|
||||||
except ValueError:
|
|
||||||
raise AccountNotFound()
|
raise AccountNotFound()
|
||||||
|
with self.browser:
|
||||||
|
account = self.browser.get_account(_id)
|
||||||
|
if account:
|
||||||
|
return account
|
||||||
else:
|
else:
|
||||||
with self.browser:
|
raise AccountNotFound()
|
||||||
account = self.browser.get_account(_id)
|
|
||||||
if account:
|
|
||||||
return account
|
|
||||||
else:
|
|
||||||
raise AccountNotFound()
|
|
||||||
|
|
||||||
def iter_history(self, account):
|
def iter_history(self, account):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
@ -92,10 +89,10 @@ class BNPorcBackend(BaseBackend, ICapBank):
|
||||||
account = account.id
|
account = account.id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
account = long(account)
|
assert account.isdigit()
|
||||||
to = long(to)
|
assert to.isdigit()
|
||||||
amount = float(amount)
|
amount = float(amount)
|
||||||
except ValueError:
|
except (AssertionError, ValueError):
|
||||||
raise AccountNotFound()
|
raise AccountNotFound()
|
||||||
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -104,14 +104,14 @@ class BNPorc(BaseBrowser):
|
||||||
return self.page.get_list()
|
return self.page.get_list()
|
||||||
|
|
||||||
def get_account(self, id):
|
def get_account(self, id):
|
||||||
assert isinstance(id, (int, long))
|
assert isinstance(id, (str, unicode))
|
||||||
|
|
||||||
if not self.is_on_page(pages.AccountsList):
|
if not self.is_on_page(pages.AccountsList):
|
||||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||||
|
|
||||||
l = self.page.get_list()
|
l = self.page.get_list()
|
||||||
for a in l:
|
for a in l:
|
||||||
if long(a.id) == id:
|
if a.id == id:
|
||||||
return a
|
return a
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class TransferPage(BasePage):
|
||||||
if table.attrib.get('cellspacing') == '2':
|
if table.attrib.get('cellspacing') == '2':
|
||||||
for tr in table.cssselect('tr.hdoc1, tr.hdotc1'):
|
for tr in table.cssselect('tr.hdoc1, tr.hdotc1'):
|
||||||
tds = tr.findall('td')
|
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 id == from_id:
|
||||||
if tds[4].find('input') is None:
|
if tds[4].find('input') is None:
|
||||||
raise TransferError("Unable to make a transfer from %s" % from_id)
|
raise TransferError("Unable to make a transfer from %s" % from_id)
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,13 @@ class CragrBackend(BaseBackend, ICapBank):
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
try:
|
if not _id.isdigit():
|
||||||
_id = long(_id)
|
|
||||||
except ValueError:
|
|
||||||
raise AccountNotFound()
|
raise AccountNotFound()
|
||||||
|
account = self.browser.get_account(_id)
|
||||||
|
if account:
|
||||||
|
return account
|
||||||
else:
|
else:
|
||||||
account = self.browser.get_account(_id)
|
raise AccountNotFound()
|
||||||
if account:
|
|
||||||
return account
|
|
||||||
else:
|
|
||||||
raise AccountNotFound()
|
|
||||||
|
|
||||||
def iter_operations(self, account):
|
def iter_operations(self, account):
|
||||||
""" TODO Not supported yet """
|
""" TODO Not supported yet """
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class Cragr(BaseBrowser):
|
||||||
return self.page.get_list()
|
return self.page.get_list()
|
||||||
|
|
||||||
def get_account(self, id):
|
def get_account(self, id):
|
||||||
assert isinstance(id, (int, long))
|
assert isinstance(id, (str, unicode))
|
||||||
|
|
||||||
l = self.get_accounts_list()
|
l = self.get_accounts_list()
|
||||||
for a in l:
|
for a in l:
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,13 @@ class LCLBackend(BaseBackend, ICapBank):
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
try:
|
if not _id.isdigit():
|
||||||
_id = long(_id)
|
|
||||||
except ValueError:
|
|
||||||
raise AccountNotFound()
|
raise AccountNotFound()
|
||||||
|
account = self.browser.get_account(_id)
|
||||||
|
if account:
|
||||||
|
return account
|
||||||
else:
|
else:
|
||||||
account = self.browser.get_account(_id)
|
raise AccountNotFound()
|
||||||
if account:
|
|
||||||
return account
|
|
||||||
else:
|
|
||||||
raise AccountNotFound()
|
|
||||||
|
|
||||||
def iter_operations(self, account):
|
def iter_operations(self, account):
|
||||||
""" TODO Not supported yet """
|
""" TODO Not supported yet """
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class LCLBrowser(BaseBrowser):
|
||||||
return self.page.get_list()
|
return self.page.get_list()
|
||||||
|
|
||||||
def get_account(self, id):
|
def get_account(self, id):
|
||||||
assert isinstance(id, (int, long))
|
assert isinstance(id, (str, unicode))
|
||||||
|
|
||||||
l = self.get_accounts_list()
|
l = self.get_accounts_list()
|
||||||
for a in l:
|
for a in l:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue