aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2008-11-15 18:35:41 -0500
committerW. Trevor King <wking@drexel.edu>2008-11-15 18:35:41 -0500
commit03011f286420d8e091052019ee41eba021041e61 (patch)
treefcf389e28c1142d61015bf37134925d4b209ba25 /libbe/bug.py
parent137f084f2931a0e2e1fa3076beadac17b88ef6b6 (diff)
downloadbugseverywhere-03011f286420d8e091052019ee41eba021041e61.tar.gz
Moved libbe.cmdutil.bug_summary() to libbe.bug.Bug.string().
This seems like a natual place for a function that only operates on Bugs.
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index b0ebca4..02c0d7a 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -88,7 +88,7 @@ class Bug(object):
severity = checked_property("severity", severity_values)
status = checked_property("status", status_values)
- def __init__(self, path, uuid, rcs_name):
+ def __init__(self, path, uuid, rcs_name, bugdir):
self.path = path
self.uuid = uuid
if uuid is not None:
@@ -97,7 +97,8 @@ class Bug(object):
dict = {}
self.rcs_name = rcs_name
-
+ self.bugdir = bugdir
+
self.summary = dict.get("summary")
self.creator = dict.get("creator")
self.target = dict.get("target")
@@ -111,6 +112,37 @@ class Bug(object):
def __repr__(self):
return "Bug(uuid=%r)" % self.uuid
+ def string(self, bugs=None, shortlist=False):
+ if shortlist == False:
+ if bugs == None:
+ bugs = list(self.bugdir.list())
+ htime = utility.handy_time(bug.time)
+ ftime = utility.time_to_str(bug.time)
+ info = [("ID", bug.uuid),
+ ("Short name", unique_name(bug, bugs)),
+ ("Severity", bug.severity),
+ ("Status", bug.status),
+ ("Assigned", bug.assigned),
+ ("Target", bug.target),
+ ("Creator", bug.creator),
+ ("Created", "%s (%s)" % (htime, ftime))]
+ newinfo = []
+ for k,v in info:
+ if v == None:
+ newinfo.append((k,""))
+ else:
+ newinfo.append((k,v))
+ info = newinfo
+ longest_key_len = max([len(k) for k,v in info])
+ infolines = [" %*s : %s\n" % (longest_key_len,k,v) for k,v in info]
+ return "".join(infolines) + "%s\n" % bug.summary
+ else:
+ statuschar = bug.status[0]
+ severitychar = bug.severity[0]
+ chars = "%c%c" % (statuschar, severitychar)
+ return "%s:%s: %s\n" % (cmdutil.unique_name(bug, bugs), chars, bug.summary)
+ def __str__(self):
+ return self.string(shortlist=True)
def get_path(self, file):
return os.path.join(self.path, self.uuid, file)