diff options
author | W. Trevor King <wking@drexel.edu> | 2008-11-15 18:35:41 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-11-15 18:35:41 -0500 |
commit | 03011f286420d8e091052019ee41eba021041e61 (patch) | |
tree | fcf389e28c1142d61015bf37134925d4b209ba25 | |
parent | 137f084f2931a0e2e1fa3076beadac17b88ef6b6 (diff) | |
download | bugseverywhere-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.
-rw-r--r-- | becommands/list.py | 3 | ||||
-rw-r--r-- | becommands/show.py | 2 | ||||
-rw-r--r-- | becommands/upgrade.py | 3 | ||||
-rw-r--r-- | libbe/bug.py | 36 | ||||
-rw-r--r-- | libbe/bugdir.py | 4 | ||||
-rw-r--r-- | libbe/cmdutil.py | 23 | ||||
-rw-r--r-- | libbe/diff.py | 6 |
7 files changed, 42 insertions, 35 deletions
diff --git a/becommands/list.py b/becommands/list.py index e127c50..6cd7826 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -107,8 +107,7 @@ def execute(args): if title != None: print cmdutil.underlined(title) for bug in cur_bugs: - print cmdutil.bug_summary(bug, all_bugs, no_target=no_target, - shortlist=True), + print bug.string(all_bugs, shortlist=True), list_bugs(bugs, no_target=False) diff --git a/becommands/show.py b/becommands/show.py index 786ba29..678a607 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -25,7 +25,7 @@ def execute(args): raise cmdutil.UserError("Please specify a bug id.") bug_dir = cmdutil.bug_tree() bug = cmdutil.get_bug(args[0], bug_dir) - print cmdutil.bug_summary(bug, list(bug_dir.list())).rstrip("\n") + print bug.string().rstrip("\n") unique_name = cmdutil.unique_name(bug, bug_dir.list()) comments = [] name_map = {} diff --git a/becommands/upgrade.py b/becommands/upgrade.py index 8f7c3a4..f5b12ef 100644 --- a/becommands/upgrade.py +++ b/becommands/upgrade.py @@ -18,7 +18,6 @@ import os.path import errno from libbe import bugdir, rcs, cmdutil -from libbe.bug import Bug def execute(args): options, args = get_parser().parse_args(args) @@ -26,7 +25,7 @@ def execute(args): for uuid in root.list_uuids(): old_bug = OldBug(root.bugs_path, uuid) - new_bug = Bug(root.bugs_path, None) + new_bug = root.get_bug(uuid) new_bug.uuid = old_bug.uuid new_bug.summary = old_bug.summary new_bug.creator = old_bug.creator 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) diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 7570bb3..f8f45b8 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -174,7 +174,7 @@ class BugDir: return bugs def get_bug(self, uuid): - return Bug(self.bugs_path, uuid, self.rcs_name) + return Bug(self.bugs_path, uuid, self.rcs_name, self) def list_uuids(self): for uuid in os.listdir(self.bugs_path): @@ -187,7 +187,7 @@ class BugDir: uuid = names.uuid() path = os.path.join(self.bugs_path, uuid) self.rcs.mkdir(path) - bug = Bug(self.bugs_path, None, self.rcs_name) + bug = Bug(self.bugs_path, None, self.rcs_name, self) bug.uuid = uuid return bug diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index 69cfe84..b5a93c7 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -72,29 +72,6 @@ def get_bug(spec, bug_dir=None): raise UserError("No bug matches %s" % spec) return matches[0] -def bug_summary(bug, bugs, no_target=False, shortlist=False): - 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)" % (utility.handy_time(bug.time),utility.time_to_str(bug.time)))] - newinfo = [] - for k,v in info: - if v == None: - newinfo.append((k,"")) - else: - newinfo.append((k,v)) - info = newinfo - if shortlist == False: - 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: - return "%s: %s\n" % (unique_name(bug, bugs), bug.summary) - def iter_commands(): for name, module in plugin.iter_plugins("becommands"): yield name.replace("_", "-"), module diff --git a/libbe/diff.py b/libbe/diff.py index 97eca54..fb3cfea 100644 --- a/libbe/diff.py +++ b/libbe/diff.py @@ -54,7 +54,7 @@ def diff_report(diff_data, bug_dir): if len(added) > 0: print "New bug reports:" for bug in added: - print cmdutil.bug_summary(bug, bugs, no_target=True) + print bug.string(shortlist=True) if len(modified) > 0: printed = False @@ -70,7 +70,7 @@ def diff_report(diff_data, bug_dir): if len(removed) > 0: print "Removed bug reports:" for bug in removed: - print cmdutil.bug_summary(bug, bugs, no_target=True) + print bug.string(bug, bugs, shortlist=True) def change_lines(old, new, attributes): change_list = [] @@ -102,7 +102,7 @@ def bug_changes(old, new, bugs): if len(change_strings) == 0: return None - return "%s%s\n" % (cmdutil.bug_summary(new, bugs, shortlist=True), + return "%s%s\n" % (new.string(bugs, shortlist=True), "\n".join(change_strings)) |