From e01b39c8d2ce4f372e4293b053f4a474efea1310 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Fri, 16 May 2014 11:43:51 +0200 Subject: [PATCH] Also ignore URLs where all kwargs were not used --- weboob/tools/browser2/page.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/weboob/tools/browser2/page.py b/weboob/tools/browser2/page.py index 1fc9d224..68e59cc2 100644 --- a/weboob/tools/browser2/page.py +++ b/weboob/tools/browser2/page.py @@ -145,13 +145,16 @@ class URL(object): for pattern, _ in patterns: url = pattern # only use full-name substitutions, to allow % in URLs - for kwkey in kwargs: + for kwkey in kwargs.keys(): # need to use keys() because of pop() search = '%%(%s)s' % kwkey if search in pattern: - url = url.replace(search, unicode(kwargs[kwkey])) + url = url.replace(search, unicode(kwargs.pop(kwkey))) # if there are named substitutions left, ignore pattern if re.search('%\([A-z_]+\)s', url): continue + # if not all kwargs were used + if len(kwargs): + continue return self.browser.absurl(url, base=True)