aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libbe/command/list.py36
-rw-r--r--libbe/command/target.py17
-rw-r--r--libbe/command/util.py21
3 files changed, 48 insertions, 26 deletions
diff --git a/libbe/command/list.py b/libbe/command/list.py
index 8baeaa2..c1bcba0 100644
--- a/libbe/command/list.py
+++ b/libbe/command/list.py
@@ -23,6 +23,8 @@ import re
import libbe
import libbe.bug
import libbe.command
+import libbe.command.depend
+import libbe.command.target
import libbe.command.util
# get a list of * for cmp_*() comparing two bugs.
@@ -30,19 +32,31 @@ AVAILABLE_CMPS = [fn[4:] for fn in dir(libbe.bug) if fn[:4] == 'cmp_']
AVAILABLE_CMPS.remove('attr') # a cmp_* template.
class Filter (object):
- def __init__(self, status, severity, assigned, extra_strings_regexps):
+ def __init__(self, status='all', severity='all', assigned='all',
+ target='all', extra_strings_regexps=[]):
self.status = status
self.severity = severity
self.assigned = assigned
+ self.target = target
self.extra_strings_regexps = extra_strings_regexps
- def __call__(self, bug):
- if self.status != "all" and not bug.status in self.status:
+ def __call__(self, bugdir, bug):
+ if self.status != 'all' and not bug.status in self.status:
return False
- if self.severity != "all" and not bug.severity in self.severity:
+ if self.severity != 'all' and not bug.severity in self.severity:
return False
- if self.assigned != "all" and not bug.assigned in self.assigned:
+ if self.assigned != 'all' and not bug.assigned in self.assigned:
return False
+ if self.target == 'all':
+ pass
+ else:
+ target_bug = libbe.command.target.bug_target(bugdir, bug)
+ if self.target in ['none', None]:
+ if target_bug.summary != None:
+ return False
+ else:
+ if target_bug.summary != self.target:
+ return False
if len(bug.extra_strings) == 0:
if len(self.extra_strings_regexps) > 0:
return False
@@ -140,9 +154,10 @@ class List (libbe.command.Command):
bugdir.storage.writeable = False
cmp_list, status, severity, assigned, extra_strings_regexps = \
self._parse_params(params)
- filter = Filter(status, severity, assigned, extra_strings_regexps)
+ filter = Filter(status, severity, assigned,
+ extra_strings_regexps=extra_strings_regexps)
bugs = [bugdir.bug_from_uuid(uuid) for uuid in bugdir.uuids()]
- bugs = [b for b in bugs if filter(b) == True]
+ bugs = [b for b in bugs if filter(bugdir, b) == True]
self.result = bugs
if len(bugs) == 0 and params['xml'] == False:
print >> self.stdout, "No matching bugs found"
@@ -191,13 +206,8 @@ class List (libbe.command.Command):
if params['assigned'] == "all":
assigned = "all"
else:
- possible_assignees = []
- for bug in self.bugdir:
- if bug.assigned != None \
- and not bug.assigned in possible_assignees:
- possible_assignees.append(bug.assigned)
assigned = libbe.command.util.select_values(
- params['assigned'], possible_assignees)
+ params['assigned'], libbe.command.util.assignees())
for i in range(len(assigned)):
if assigned[i] == '-':
assigned[i] = params['user-id']
diff --git a/libbe/command/target.py b/libbe/command/target.py
index 0161772..4bfe82e 100644
--- a/libbe/command/target.py
+++ b/libbe/command/target.py
@@ -185,15 +185,24 @@ def add_target(bugdir, bug, summary):
return target
def targets(bugdir):
+ """Generate all possible target bug summaries."""
bugdir.load_all_bugs()
for bug in bugdir:
if bug.severity == 'target':
yield bug.summary
-def complete_target(command, argument, fragment=None):
+def target_dict(bugdir):
"""
- List possible command completions for fragment.
-
- argument argument is not used.
+ Return a dict with bug UUID keys and bug summary values for all
+ target bugs.
"""
+ ret = {}
+ bugdir.load_all_bugs()
+ for bug in bugdir:
+ if bug.severity == 'target':
+ ret[bug.uuid] = bug.summary
+ return ret
+
+def complete_target(command, argument, fragment=None):
+ """List possible command completions for fragment."""
return targets(command._get_bugdir())
diff --git a/libbe/command/util.py b/libbe/command/util.py
index c9618ad..977b596 100644
--- a/libbe/command/util.py
+++ b/libbe/command/util.py
@@ -34,12 +34,8 @@ def complete_command(command, argument, fragment=None):
"""
return list(libbe.command.commands())
-def complete_path(command, argument, fragment=None):
- """
- List possible path completions for fragment.
-
- command argument is not used.
- """
+def comp_path(fragment=None):
+ """List possible path completions for fragment."""
if fragment == None:
fragment = '.'
comps = glob.glob(fragment+'*') + glob.glob(fragment+'/*')
@@ -47,6 +43,10 @@ def complete_path(command, argument, fragment=None):
comps.extend(glob.glob(comps[0]+'/*'))
return comps
+def complete_path(command, argument, fragment=None):
+ """List possible path completions for fragment."""
+ return comp_path(fragment)
+
def complete_status(command, argument, fragment=None):
bd = command._get_bugdir()
import libbe.bug
@@ -57,10 +57,13 @@ def complete_severity(command, argument, fragment=None):
import libbe.bug
return libbe.bug.severity_values
+def assignees(bugdir):
+ bugdir.load_all_bugs()
+ return list(set([bug.assigned for bug in bugdir
+ if bug.assigned != None]))
+
def complete_assigned(command, argument, fragment=None):
- if fragment == None:
- return []
- return [fragment]
+ return assignees(command._get_bugdir())
def complete_extra_strings(command, argument, fragment=None):
if fragment == None: