Introduce find_id_list

And code simplification in backends/browsers
This commit is contained in:
Florent 2014-04-01 17:40:38 +02:00
commit 080c4aff81
5 changed files with 27 additions and 60 deletions

View file

@ -48,25 +48,7 @@ class PoivyBrowser(LoginBrowser):
def get_subscription_list(self):
return self.homepage.stay_or_go().get_list()
def _find_id_list(self, mylist, _id):
for a in mylist:
if a.id == _id:
return a
return None
@need_login
def get_subscription(self, _id):
return self._find_id_list(self.get_subscription_list(), _id)
@need_login
def get_history(self):
self.history.stay_or_go()
return self.pagination(lambda: self.page.get_calls())
@need_login
def iter_bills(self, parentid):
return self.bills.stay_or_go().get_bills()
@need_login
def get_bill(self, _id):
return self._find_id_list(self.iter_bills(), _id)