add UrlNotResolvable exception when URL.build can't resolve url with keywords
This commit is contained in:
parent
fca0ab8733
commit
266300ab65
1 changed files with 10 additions and 1 deletions
|
|
@ -34,6 +34,10 @@ from .browser import DomainBrowser
|
|||
from .filters import _Filter, CleanText
|
||||
|
||||
|
||||
class UrlNotResolvable(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class URL(object):
|
||||
"""
|
||||
A description of an URL on the PagesBrowser website.
|
||||
|
|
@ -93,9 +97,14 @@ class URL(object):
|
|||
patterns += normalize(url)
|
||||
|
||||
for pattern, args in patterns:
|
||||
url = pattern % kwargs
|
||||
try:
|
||||
url = pattern % kwargs
|
||||
except KeyError:
|
||||
continue
|
||||
return url
|
||||
|
||||
raise UrlNotResolvable('Unable to resolve URL with %r. Available are %s' % (kwargs, ', '.join([pattern for pattern, args in patterns])))
|
||||
|
||||
def match(self, url):
|
||||
for regex in self.urls:
|
||||
if regex.startswith('/'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue