From 57c61e2e78078322bfae6b338bede66ec3107203 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 25 Jun 2010 14:31:34 -0400 Subject: Added --tags to `be list`. And broke out tagging functions in libbe.command.tag, so they are accessible to other commands. --- libbe/command/list.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'libbe/command/list.py') diff --git a/libbe/command/list.py b/libbe/command/list.py index a522b4a..197604b 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -25,6 +25,7 @@ import libbe import libbe.bug import libbe.command import libbe.command.depend +import libbe.command.tag import libbe.command.target import libbe.command.util @@ -127,6 +128,8 @@ class List (libbe.command.Command): arg=libbe.command.Argument( name='sort', metavar='SORT', default=None, completion_callback=libbe.command.util.Completer(AVAILABLE_CMPS))), + libbe.command.Option(name='tags', short_name='t', + help='Add TAGS: field to standard listing format.'), libbe.command.Option(name='ids', short_name='i', help='Only print the bug IDS'), libbe.command.Option(name='xml', short_name='x', @@ -173,7 +176,7 @@ class List (libbe.command.Command): for bug in bugs: print >> self.stdout, bug.id.user() else: - self._list_bugs(bugs, xml=params['xml']) + self._list_bugs(bugs, show_tags=params['tags'], xml=params['xml']) bugdir.storage.writeable = writeable return 0 @@ -230,7 +233,7 @@ class List (libbe.command.Command): bugs.sort(cmp_fn) return bugs - def _list_bugs(self, bugs, xml=False): + def _list_bugs(self, bugs, show_tags=False, xml=False): if xml == True: print >> self.stdout, \ '' % self.stdout.encoding @@ -240,18 +243,27 @@ class List (libbe.command.Command): if xml == True: print >> self.stdout, bug.xml(show_comments=True) else: - print >> self.stdout, bug.string(shortlist=True) + bug_string = bug.string(shortlist=True) + if show_tags == True: + attrs,summary = bug_string.split(' ', 1) + bug_string = ( + '%s%s: %s' + % (attrs, + ','.join(libbe.command.tag.get_tags(bug)), + summary)) + print >> self.stdout, bug_string if xml == True: print >> self.stdout, '' def _long_help(self): return """ This command lists bugs. Normally it prints a short string like - bea/576:om: Allow attachments + bea/576:om:[TAGS:] Allow attachments Where bea/576 the bug id o the bug status is 'open' (first letter) m the bug severity is 'minor' (first letter) + TAGS comma-separated list of bug tags (if --tags is set) Allo... the bug summary string You can optionally (-u) print only the bug ids. -- cgit From 1791da7a299980d45c5891eb3e21280b58e70c7b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 25 Jun 2010 14:49:39 -0400 Subject: Reworked `be list --extra-strings REGEXP` logic. Previous implementation only matched if *every* regexp matched *every* string. Current implementation matches is *any* regexp matches *any* string. --- libbe/command/list.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libbe/command/list.py') diff --git a/libbe/command/list.py b/libbe/command/list.py index 197604b..c62e5a4 100644 --- a/libbe/command/list.py +++ b/libbe/command/list.py @@ -63,10 +63,16 @@ class Filter (object): if len(self.extra_strings_regexps) > 0: return False else: + matched = False for string in bug.extra_strings: for regexp in self.extra_strings_regexps: - if not regexp.match(string): - return False + if regexp.match(string): + matched = True + break + if matched == True: + break + if matched == False: + return False return True class List (libbe.command.Command): -- cgit