aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/list.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
commit4e5dc3888699076e46bdc1d94f901ca889b88b05 (patch)
tree752955efc584d113261c5e5c865faf51113703d8 /becommands/list.py
parent0f6e647f18a2d6165c0333cb7d123fc781c8e4e1 (diff)
downloadbugseverywhere-4e5dc3888699076e46bdc1d94f901ca889b88b05.tar.gz
Added `be list --sort *` for user-selectable sorting.
Also added libbe.bug.cmp_last_modified, which handles part of 9ce2f015-8ea0-43a5-a03d-fc36f6d202fe. To do better we could extend the RCS framework. I also transcribed a few emails from the be-devel list onto their relavent bugs and closed a few bugs. Finally, I removed some left over InvalidValue cruft.
Diffstat (limited to 'becommands/list.py')
-rw-r--r--becommands/list.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/becommands/list.py b/becommands/list.py
index 9f4e037..1f06569 100644
--- a/becommands/list.py
+++ b/becommands/list.py
@@ -19,6 +19,10 @@ from libbe import cmdutil, bugdir, bug
import os
__desc__ = __doc__
+# get a list of * for cmp_*() comparing two bugs.
+AVAILABLE_CMPS = [fn[4:] for fn in dir(bug) if fn[:4] == 'cmp_']
+AVAILABLE_CMPS.remove("attr") # a cmp_* template.
+
def execute(args, test=False):
"""
>>> import os
@@ -35,6 +39,13 @@ def execute(args, test=False):
complete(options, args, parser)
if len(args) > 0:
raise cmdutil.UsageError("Too many arguments.")
+ cmp_list = []
+ if options.sort_by != None:
+ for cmp in options.sort_by.split(','):
+ if cmp not in AVAILABLE_CMPS:
+ raise cmdutil.UserError("Invalid sort on '%s'.\nValid sorts:\n %s"
+ % (cmp, '\n '.join(AVAILABLE_CMPS)))
+ cmp_list.append(eval('bug.cmp_%s' % cmp))
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bd.load_all_bugs()
@@ -115,7 +126,6 @@ def execute(args, test=False):
print "No matching bugs found"
def list_bugs(cur_bugs, title=None, just_uuids=False, xml=False):
- cur_bugs.sort(bug.cmp_full)
if xml == True:
print "<bugs>"
if len(cur_bugs) > 0:
@@ -130,7 +140,13 @@ def execute(args, test=False):
print bg.string(shortlist=True)
if xml == True:
print "</bugs>"
-
+
+ # sort bugs
+ cmp_list.extend(bug.DEFAULT_CMP_FULL_CMP_LIST)
+ cmp_fn = bug.BugCompoundComparator(cmp_list=cmp_list)
+ bugs.sort(cmp_fn)
+
+ # print list of bugs
list_bugs(bugs, just_uuids=options.uuids, xml=options.xml)
def get_parser():
@@ -143,6 +159,8 @@ def get_parser():
help="List options matching ASSIGNED", default=None)
parser.add_option("-t", "--target", metavar="TARGET", dest="target",
help="List options matching TARGET", default=None)
+ parser.add_option("-S", "--sort", metavar="SORT-BY", dest="sort_by",
+ help="Adjust bug-sort criteria with comma-separated list SORT-BY. e.g. \"--sort creator,time\". Available criteria: %s" % ','.join(AVAILABLE_CMPS), default=None)
# boolean options. All but uuids and xml are special cases of long forms
bools = (("u", "uuids", "Only print the bug UUIDS"),
("w", "wishlist", "List bugs with 'wishlist' severity"),