aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/comment.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-22 12:20:09 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-22 12:20:09 -0400
commit11556f64815eeba2bb9bea5fd804841152d836bd (patch)
treea1e5b94a8d294f123001f33995d99a3b9bdc69d7 /libbe/comment.py
parent665e64fbe8fea91f68be42cbbda79082d9a58c30 (diff)
parent107c15bfd9c5702554d14583dd589226cc573985 (diff)
downloadbugseverywhere-11556f64815eeba2bb9bea5fd804841152d836bd.tar.gz
Merged be-xml-to-mbox
Diffstat (limited to 'libbe/comment.py')
-rw-r--r--libbe/comment.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/libbe/comment.py b/libbe/comment.py
index e5c86c7..d0fa5ee 100644
--- a/libbe/comment.py
+++ b/libbe/comment.py
@@ -19,6 +19,7 @@
import os
import os.path
import time
+import xml.sax.saxutils
import textwrap
import doctest
@@ -223,8 +224,8 @@ class Comment(Tree, settings_object.SavedSettingsObject):
>>> comm.time_string = "Thu, 01 Jan 1970 00:00:00 +0000"
>>> print comm.xml(indent=2, shortname="com-1")
<comment>
- <name>com-1</name>
<uuid>0123</uuid>
+ <short-name>com-1</short-name>
<from></from>
<date>Thu, 01 Jan 1970 00:00:00 +0000</date>
<body>Some
@@ -234,16 +235,17 @@ class Comment(Tree, settings_object.SavedSettingsObject):
"""
if shortname == None:
shortname = self.uuid
- lines = ["<comment>",
- " <name>%s</name>" % (shortname,),
- " <uuid>%s</uuid>" % self.uuid,]
- if self.in_reply_to != None:
- lines.append(" <in_reply_to>%s</in_reply_to>" % self.in_reply_to)
- lines.extend([
- " <from>%s</from>" % self._setting_attr_string("From"),
- " <date>%s</date>" % self.time_string,
- " <body>%s</body>" % (self.body or "").rstrip('\n'),
- "</comment>\n"])
+ info = [("uuid", self.uuid),
+ ("short-name", shortname),
+ ("in-reply-to", self.in_reply_to),
+ ("from", self._setting_attr_string("From")),
+ ("date", self.time_string),
+ ("body", (self.body or "").rstrip('\n'))]
+ lines = ["<comment>"]
+ for (k,v) in info:
+ if v not in [settings_object.EMPTY, None]:
+ lines.append(' <%s>%s</%s>' % (k,xml.sax.saxutils.escape(v),k))
+ lines.append("</comment>")
istring = ' '*indent
sep = '\n' + istring
return istring + sep.join(lines).rstrip('\n')