diff options
author | W. Trevor King <wking@drexel.edu> | 2009-11-20 17:09:08 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-11-20 17:09:08 -0500 |
commit | 75fedab07f9e566ca1c984051d7deece4d910e2c (patch) | |
tree | bd986b4758653212b2ea580b8ab0bd29e3faa424 /libbe/utility.py | |
parent | ccfd3f9b65eba4535d7975395dc689eea40b0547 (diff) | |
download | bugseverywhere-75fedab07f9e566ca1c984051d7deece4d910e2c.tar.gz |
Added Bug.from_xml() + some .from_xml() fixups.
Moved comment.InvalidXML to utility.InvalidXML, so that bug and
comment can share it. Added docstring explaining the __init__
arguments.
Added indent and shortname options to Bug.xml() to match
Comment.xml().
Added .extra_strings export to Comment.xml().
Converted Bug.xml() from string addition to list joining, which avoids
a bunch of memory allocation/deallocation.
Assorted " -> ' replacements.
Elaborated doctests to check UTF-8, extra_strings, ...
Added new comparison cmp_extra_strings for both bug. and
comment.DEFAULT_CMP_FULL_CMP_LIST.
Diffstat (limited to 'libbe/utility.py')
-rw-r--r-- | libbe/utility.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libbe/utility.py b/libbe/utility.py index 4126913..7510b16 100644 --- a/libbe/utility.py +++ b/libbe/utility.py @@ -29,6 +29,21 @@ import time import types import doctest +class InvalidXML(ValueError): + """ + Invalid XML while parsing for a *.from_xml() method. + type - string identifying *, e.g. "bug", "comment", ... + element - ElementTree.Element instance which caused the error + error - string describing the error + """ + def __init__(self, type, element, error): + msg = 'Invalid %s xml: %s\n %s\n' \ + % (type, error, ElementTree.tostring(element)) + ValueError.__init__(self, msg) + self.type = type + self.element = element + self.error = error + def search_parent_directories(path, filename): """ Find the file (or directory) named filename in path or in any |