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"]))
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",
def reset(self):
self.bug = None
self.comment = None
+ self.extra_strings = None
self.text_field = None
def startElement(self, name, attributes):
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
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: