add UrlNotResolvable exception when URL.build can't resolve url with keywords

This commit is contained in:
Romain Bignon 2014-03-13 22:05:33 +01:00
commit 266300ab65

View file

@ -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('/'):