Support multiple account for details operation

This commit is contained in:
Florent 2012-08-27 14:54:50 +02:00
commit adce6d0c83
4 changed files with 59 additions and 45 deletions

View file

@ -50,8 +50,7 @@ class FreeMobileBackend(BaseBackend, ICapBill):
self.config['password'].get())
def iter_subscription(self):
for subscription in self.browser.get_subscription_list():
yield subscription
return self.browser.get_subscription_list()
def get_subscription(self, _id):
if not _id.isdigit():
@ -64,10 +63,14 @@ class FreeMobileBackend(BaseBackend, ICapBill):
raise SubscriptionNotFound()
def iter_history(self, subscription):
if not isinstance(subscription, Subscription):
subscription = self.get_subscription(subscription)
with self.browser:
for history in self.browser.get_history():
for history in self.browser.get_history(subscription):
yield history
def get_bill(self, id):
with self.browser:
bill = self.browser.get_bill(id)
@ -76,6 +79,7 @@ class FreeMobileBackend(BaseBackend, ICapBill):
else:
raise BillNotFound()
def iter_bills(self, subscription):
if not isinstance(subscription, Subscription):
subscription = self.get_subscription(subscription)
@ -84,12 +88,16 @@ class FreeMobileBackend(BaseBackend, ICapBill):
for bill in self.browser.iter_bills(subscription.id):
yield bill
# The subscription is actually useless, but maybe for the futur...
def get_details(self, subscription):
if not isinstance(subscription, Subscription):
subscription = self.get_subscription(subscription)
with self.browser:
for detail in self.browser.get_details():
for detail in self.browser.get_details(subscription):
yield detail
def download_bill(self, bill):
if not isinstance(bill, Bill):
bill = self.get_bill(bill)