Allow more freedom in page regexps

If the user starts with ^ or ends with $, do not add them. This allows
using only $ or ^.
If it's not a string, don't do anything to it (it has to be a regexp, or
mimic one).
Use search() instead of match(). They are the same, except match implies ^.

This does not break any module, it only adds more possibilities.
This commit is contained in:
Laurent Bachelier 2012-02-01 22:49:21 +01:00
commit 1621f3c3c0

View file

@ -536,8 +536,14 @@ class BaseBrowser(StandardBrowser):
page_groups = None
page_group_dict = None
for key, value in self.PAGES.items():
regexp = re.compile('^%s$' % key)
m = regexp.match(result.geturl())
if isinstance(key, basestring):
if not key.startswith('^') and not key.endswith('$'):
regexp = re.compile('^%s$' % key)
else:
regexp = re.compile(key)
else:
regexp = key
m = regexp.search(result.geturl())
if m:
pageCls = value
page_groups = m.groups()