Mercurial > piecrust2
comparison piecrust/uriutil.py @ 942:e1b33cbf9874
internal: Give better exception messages when splitting URIs.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 05 Oct 2017 00:21:50 -0700 |
parents | 4850f8c21b6e |
children |
comparison
equal
deleted
inserted
replaced
941:cf4169795f62 | 942:e1b33cbf9874 |
---|---|
14 | 14 |
15 def split_uri(app, uri): | 15 def split_uri(app, uri): |
16 root = app.config.get('site/root') | 16 root = app.config.get('site/root') |
17 uri_root = uri[:len(root)] | 17 uri_root = uri[:len(root)] |
18 if uri_root != root: | 18 if uri_root != root: |
19 raise Exception("URI '%s' is not a full URI." % uri) | 19 raise Exception("URI '%s' is not a full URI, expected root '%s'." % |
20 (uri, root)) | |
20 uri = uri[len(root):] | 21 uri = uri[len(root):] |
21 return uri_root, uri | 22 return uri_root, uri |
22 | 23 |
23 | 24 |
24 def split_sub_uri(app, uri): | 25 def split_sub_uri(app, uri): |
25 root = app.config.get('site/root') | 26 root = app.config.get('site/root') |
26 if not uri.startswith(root): | 27 if not uri.startswith(root): |
27 raise Exception("URI '%s' is not a full URI." % uri) | 28 raise Exception("URI '%s' is not a full URI, expected root '%s'." % |
29 (uri, root)) | |
28 | 30 |
29 pretty_urls = app.config.get('site/pretty_urls') | 31 pretty_urls = app.config.get('site/pretty_urls') |
30 trailing_slash = app.config.get('site/trailing_slash') | 32 trailing_slash = app.config.get('site/trailing_slash') |
31 if not pretty_urls: | 33 if not pretty_urls: |
32 uri, ext = os.path.splitext(uri) | 34 uri, ext = os.path.splitext(uri) |