correctly use iterators
This commit is contained in:
parent
9bdd96271c
commit
3be3689439
2 changed files with 4 additions and 8 deletions
|
|
@ -84,8 +84,7 @@ class CragrBackend(BaseBackend, ICapBank):
|
||||||
self.config['password'].get())
|
self.config['password'].get())
|
||||||
|
|
||||||
def iter_accounts(self):
|
def iter_accounts(self):
|
||||||
for account in self.browser.get_accounts_list():
|
return self.browser.get_accounts_list()
|
||||||
yield account
|
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
if not _id.isdigit():
|
if not _id.isdigit():
|
||||||
|
|
@ -97,9 +96,7 @@ class CragrBackend(BaseBackend, ICapBank):
|
||||||
raise AccountNotFound()
|
raise AccountNotFound()
|
||||||
|
|
||||||
def iter_history(self, account):
|
def iter_history(self, account):
|
||||||
for history in self.browser.get_history(account):
|
return self.browser.get_history(account)
|
||||||
yield history
|
|
||||||
|
|
||||||
|
|
||||||
def transfer(self, account, to, amount, reason=None):
|
def transfer(self, account, to, amount, reason=None):
|
||||||
return self.browser.do_transfer(account, to, amount, reason)
|
return self.browser.do_transfer(account, to, amount, reason)
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,6 @@ class AccountsList(CragrBasePage):
|
||||||
"""
|
"""
|
||||||
Returns the list of available bank accounts
|
Returns the list of available bank accounts
|
||||||
"""
|
"""
|
||||||
l = []
|
|
||||||
for div in self.document.getiterator('div'):
|
for div in self.document.getiterator('div'):
|
||||||
if div.attrib.get('class', '') in ('dv', 'headline') and div.getchildren()[0].tag in ('a', 'br'):
|
if div.attrib.get('class', '') in ('dv', 'headline') and div.getchildren()[0].tag in ('a', 'br'):
|
||||||
self.logger.debug("Analyzing div %s" % div)
|
self.logger.debug("Analyzing div %s" % div)
|
||||||
|
|
@ -128,8 +127,8 @@ class AccountsList(CragrBasePage):
|
||||||
self.logger.debug(' the history link appears to be %s' % account._link_id)
|
self.logger.debug(' the history link appears to be %s' % account._link_id)
|
||||||
else:
|
else:
|
||||||
account._link_id = None
|
account._link_id = None
|
||||||
l.append(account)
|
|
||||||
return l
|
yield account
|
||||||
|
|
||||||
def get_history(self, start_index=0, start_offset=0):
|
def get_history(self, start_index=0, start_offset=0):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue