aboutsummaryrefslogtreecommitdiffstats
path: root/xml/be-xml-to-mbox
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2009-06-25 13:44:27 -0400
committerChris Ball <cjb@laptop.org>2009-06-25 13:44:27 -0400
commit34b2884112e3c3ca0cc0ac83df68c66f6b2729c4 (patch)
tree7a1f3589de72cf53cf33d815ac49ddd1fb2f5fd5 /xml/be-xml-to-mbox
parentae52bd5946df9c0d59be43824b20d33819891f93 (diff)
parent93402b914313e102aa56d5d59a2fead428ae8463 (diff)
downloadbugseverywhere-34b2884112e3c3ca0cc0ac83df68c66f6b2729c4.tar.gz
Merge be --version code from W. Trevor King.
Diffstat (limited to 'xml/be-xml-to-mbox')
-rwxr-xr-xxml/be-xml-to-mbox27
1 files changed, 19 insertions, 8 deletions
diff --git a/xml/be-xml-to-mbox b/xml/be-xml-to-mbox
index 7d07bac..b0a4cba 100755
--- a/xml/be-xml-to-mbox
+++ b/xml/be-xml-to-mbox
@@ -81,7 +81,8 @@ class Bug (LimitedAttrDict):
u"creator",
u"created",
u"summary",
- u"comments"]
+ u"comments",
+ u"extra_strings"]
def print_to_mbox(self):
name,addr = email.utils.parseaddr(self["creator"])
print "From %s %s" % (addr, rfc2822_to_asctime(self["created"]))
@@ -94,8 +95,12 @@ class Bug (LimitedAttrDict):
print ""
print self["summary"]
print ""
+ if len(self["extra_strings"]) > 0:
+ print "extra strings:\n ",
+ print '\n '.join(self["extra_strings"])
+ print ""
for comment in self["comments"]:
- comment.print_to_mbox(self)
+ comment.print_to_mbox(self)
class Comment (LimitedAttrDict):
_attrs = [u"uuid",
@@ -128,6 +133,7 @@ class BE_list_handler (ContentHandler):
def reset(self):
self.bug = None
self.comment = None
+ self.extra_strings = None
self.text_field = None
def startElement(self, name, attributes):
@@ -135,16 +141,16 @@ class BE_list_handler (ContentHandler):
assert self.bug == None, "Nested bugs?!"
assert self.comment == None
assert self.text_field == None
- self.bug = Bug(comments=[])
+ self.bug = Bug(comments=[], extra_strings=[])
elif name == "comment":
assert self.bug != None, "<comment> not in <bug>?"
+ assert self.comment == None, "Nested comments?!"
assert self.text_field == None, "<comment> in text field %s?" % self.text_field
self.comment = Comment()
elif self.bug != None and self.comment == None:
# parse bug text field
- if name != "comment":
- self.text_field = name
- self.text_data = ""
+ self.text_field = name
+ self.text_data = ""
elif self.bug != None and self.comment != None:
# parse comment text field
self.text_field = name
@@ -153,18 +159,23 @@ class BE_list_handler (ContentHandler):
def endElement(self, name):
if name == "bug":
assert self.bug != None, "Invalid XML?"
+ assert self.comment == None, "Invalid XML?"
+ assert self.text_field == None, "Invalid XML?"
self.bug.print_to_mbox()
self.bug = None
elif name == "comment":
assert self.bug != None, "<comment> not in <bug>?"
- assert self.text_field == None, "<comment> in text field %s?" % self.text_field
assert self.comment != None, "Invalid XML?"
+ assert self.text_field == None, "<comment> in text field %s?" % self.text_field
self.bug["comments"].append(self.comment)
# comments printed by bug.print_to_mbox()
self.comment = None
elif self.bug != None and self.comment == None:
# parse bug text field
- self.bug[self.text_field] = unescape(self.text_data.strip())
+ if self.text_field == "extra-string":
+ self.bug["extra_strings"].append(unescape(self.text_data.strip()))
+ else:
+ self.bug[self.text_field] = unescape(self.text_data.strip())
self.text_field = None
self.text_data = None
elif self.bug != None and self.comment != None: