Commit 5ebc341b authored by Benjamin Tampigny's avatar Benjamin Tampigny Committed by Vincent A

[cragr] don't crash if subscription is found multiple times

This can happen because it is displayed twice (bank statement + deffered
statements). But the attributes of the subscription were the same.
Before this changes, the duplicates were supposed to be handled by the
variable parsed_subscription_ids but its values were given only at the
first iteration, so it was just an empty list and the condition was
always True.
Since the regexp which get some information on the subscription is now
used once per subscription, there were no need to make a method of it.
parent ae823412
......@@ -1290,9 +1290,6 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
# We have been logged out.
# Some subscriptions exist in 2 occurences in the page: e.g. one account has regular bank statement reports + deffered statements
# We use this variable not to parse a subscription twice and cause trouble
parsed_subscription_ids = []
for contract in self.iter_spaces():
token =
......@@ -1303,9 +1300,8 @@ class CreditAgricoleBrowser(LoginBrowser, StatesMixin):
except HTTPNotFound:
for sub in
for sub in
sub._contract = contract
yield sub
......@@ -43,25 +43,20 @@ class SubscriptionsDocumentsPage(LoggedPage, HTMLPage):
class iter_subscription(ListElement):
# Some subscriptions exist in 2 occurences in the page: e.g. one account has regular bank statement reports + deffered statements
# there might be duplicate, but not a big deal weboob is good and will keep only one subscription.
ignore_duplicate = True
item_xpath = '//div[contains(text(), "RELEVES DE COMPTES")]/following-sibling::table//tr//div[contains(@class, "table")]'
class item(ItemElement):
klass = Subscription
def get_account_information(self):
def parse(self, el):
raw = CleanText('./a')(self)
# raw = account_name account_id account_owner
m = re.match(r'([A-Za-z ]+) (\d+) (.+)$', raw)
assert m, 'Format of line is not: ACT 123456789 M. First Last'
return m.groups()
def condition(self):
# We check if the subscription hasn't been already parsed
_, account_id, _ = self.get_account_information()
return account_id not in Env('parsed_subscription_ids')(self)
def parse(self, el):
self.env['account_name'], self.env['account_id'], self.env['account_owner'] = self.get_account_information()
self.env['account_name'], self.env['account_id'], self.env['account_owner'] = m.groups()
obj_label = Format('%s %s', Env('account_name'), Env('account_owner'))
obj_subscriber = Env('account_owner')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment