| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Trac
Revision: 7490
Author: ecarter
Date: 20 Aug 2008 23:57:51
Diff at Trac: http://trac.edgewall.org/changeset/7490
Changes:Trunk: Merge of r7487, a whitespace cleanup, for thatch
Files:| ... | ...@@ -64,26 +64,26 @@ | |
| 64 | 64 | if etree: |
| 65 | 65 | class _Resolver(etree.Resolver): |
| 66 | 66 | base_dir = dirname(abspath(__file__)) |
| 67 | ||
| 67 | ||
| 68 | 68 | def resolve(self, system_url, public_id, context): |
| 69 | return self.resolve_filename(join(self.base_dir, | |
| 69 | return self.resolve_filename(join(self.base_dir, | |
| 70 | 70 | system_url.split("/")[-1]), |
| 71 | 71 | context) |
| 72 | ||
| 72 | ||
| 73 | 73 | _parser = etree.XMLParser(dtd_validation=True) |
| 74 | 74 | _parser.resolvers.add(_Resolver()) |
| 75 | 75 | etree.set_default_parser(_parser) |
| 76 | ||
| 76 | ||
| 77 | 77 | def _format_error_log(data, log): |
| 78 | 78 | msg = [] |
| 79 | 79 | for each in log: |
| 80 | context = data.splitlines()[max(0, each.line - 5): | |
| 80 | context = data.splitlines()[max(0, each.line - 5): | |
| 81 | 81 | each.line + 6] |
| 82 | 82 | msg.append("%s\n\nURL: %s\nLine %d, column %d\n\n%s" % ( |
| 83 | 83 | each.message, each.filename, each.line, each.column, |
| 84 | 84 | "\n".join(context))) |
| 85 | 85 | return "\n".join(msg) |
| 86 | ||
| 86 | ||
| 87 | 87 | def _validate_xhtml(func_name, *args, **kwargs): |
| 88 | 88 | page = b.get_html() |
| 89 | 89 | if "xhtml1-strict.dtd" not in page: |
| ... | ...@@ -94,9 +94,9 @@ | |
| 94 | 94 | except etree.XMLSyntaxError, e: |
| 95 | 95 | raise twill.errors.TwillAssertionError( |
| 96 | 96 | _format_error_log(page, e.error_log)) |
| 97 | ||
| 97 | ||
| 98 | 98 | b._post_load_hooks.append(_validate_xhtml) |
| 99 | ||
| 99 | ||
| 100 | 100 | # When we can't find something we expected, or find something we didn't |
| 101 | 101 | # expect, it helps the debugging effort to have a copy of the html to |
| 102 | 102 | # analyze. |