aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-19 14:42:15 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-19 14:42:15 -0400
commit89b2ba997492895328203c3d80cfd8a66dd17363 (patch)
tree7e2eaf73205bf83a6d78dcc6880d9489729ee486 /libbe/bug.py
parent8949c86542fcabbe1ddea8e9936c4436698654db (diff)
parentbd8d5fdc0d37970824daac68f8d7c76975e9d36d (diff)
downloadbugseverywhere-89b2ba997492895328203c3d80cfd8a66dd17363.tar.gz
Merged Thomas Habets 2009-01-07 XML output for "be show".
I rewrote a few of his routines, e.g. generalizing Comment.string_thread to run a caller-specified method avoided the need for some duplicate code in Comment.xml_thread. There was also a reasonable reorganization of libbe.settings_object.versioned_property because the <in_reply_to> field of the Comment.xml output was giving me `-1' (= old settings_object.EMPTY) instead of None, even after I had set comm.in_reply_to to None. The rewritten versioned_property avoids the ambiguity of UNPRIMED vs EMPTY, and avoids the stupididy of my using EMPTY=-1 ;).
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index f871c7a..fe059fa 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -235,6 +235,42 @@ class Bug(settings_object.SavedSettingsObject):
else:
return str(value)
+ def xml(self, show_comments=False):
+ if self.bugdir == None:
+ shortname = self.uuid
+ else:
+ shortname = self.bugdir.bug_shortname(self)
+
+ if self.time == None:
+ timestring = ""
+ else:
+ htime = utility.handy_time(self.time)
+ ftime = utility.time_to_str(self.time)
+ timestring = "%s (%s)" % (htime, ftime)
+
+ info = [("uuid", self.uuid),
+ ("short-name", shortname),
+ ("severity", self.severity),
+ ("status", self.status),
+ ("assigned", self.assigned),
+ ("target", self.target),
+ ("reporter", self.reporter),
+ ("creator", self.creator),
+ ("created", timestring),
+ ("summary", self.summary)]
+ ret = '<bug>\n'
+ for (k,v) in info:
+ if v is not None:
+ ret += ' <%s>%s</%s>\n' % (k,v,k)
+
+ if show_comments == True:
+ comout = self.comment_root.xml_thread(auto_name_map=True,
+ bug_shortname=shortname)
+ ret += comout
+
+ ret += '</bug>'
+ return ret
+
def string(self, shortlist=False, show_comments=False):
if self.bugdir == None:
shortname = self.uuid