From 380889988b6d7881c4e0b5968053f85676d27211 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 15 Dec 2009 04:32:19 -0500 Subject: [PATCH] Fixed libbe.command.subscribe --- libbe/command/diff.py | 2 +- libbe/command/subscribe.py | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libbe/command/diff.py b/libbe/command/diff.py index 6a7c36b..c8b5777 100644 --- a/libbe/command/diff.py +++ b/libbe/command/diff.py @@ -74,7 +74,7 @@ class Diff (libbe.command.Command): completion_callback=libbe.command.util.complete_path)), libbe.command.Option(name='subscribe', short_name='s', help='Only print changes matching SUBSCRIPTION, ' - 'subscription is a comma-separ\ated list of ID:TYPE ' + 'subscription is a comma-separated list of ID:TYPE ' 'tuples. See `be subscribe --help` for descriptions ' 'of ID and TYPE.', arg=libbe.command.Argument( diff --git a/libbe/command/subscribe.py b/libbe/command/subscribe.py index e86a9c8..4f72624 100644 --- a/libbe/command/subscribe.py +++ b/libbe/command/subscribe.py @@ -22,6 +22,7 @@ import libbe.bug import libbe.command import libbe.diff import libbe.command.util +import libbe.util.id import libbe.util.tree @@ -54,19 +55,19 @@ class Subscribe (libbe.command.Command): Jane Doe all a.com,b.net John Doe all * >>> ret = cmd.run({'subscriber':'Jane Doe ', 'servers':'a.edu'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE - Subscriptions for a: + Subscriptions for abc/a: Jane Doe all a.com,a.edu,b.net John Doe all * >>> ret = cmd.run({'unsubscribe':True, 'subscriber':'Jane Doe ', 'servers':'a.com'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE - Subscriptions for a: + Subscriptions for abc/a: Jane Doe all a.edu,b.net John Doe all * >>> ret = cmd.run({'subscriber':'Jane Doe ', 'servers':'*'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE - Subscriptions for a: + Subscriptions for abc/a: Jane Doe all * John Doe all * >>> ret = cmd.run({'unsubscribe':True, 'subscriber':'Jane Doe '}, ['/a']) # doctest: +NORMALIZE_WHITESPACE - Subscriptions for a: + Subscriptions for abc/a: John Doe all * >>> ret = cmd.run({'unsubscribe':True, 'subscriber':'John Doe '}, ['/a']) >>> ret = cmd.run({'subscriber':'Jane Doe ', 'types':'new'}, ['DIR']) # doctest: +NORMALIZE_WHITESPACE @@ -103,7 +104,7 @@ class Subscribe (libbe.command.Command): ]) self.args.extend([ libbe.command.Argument( - name='id', metavar='ID', default=None, + name='id', metavar='ID', default=tuple(), optional=True, repeatable=True, completion_callback=libbe.command.util.complete_bug_comment_id), ]) @@ -131,17 +132,17 @@ class Subscribe (libbe.command.Command): servers = params['servers'].split(',') types = params['types'].split(',') - if params['id'] == None: - params['id'] = libbe.diff.BUGDIR_ID - for id in params['id']: - if id == libbe.diff.BUGDIR_ID: # directory-wide subscriptions + if len(params['id']) == 0: + params['id'] = [libbe.diff.BUGDIR_ID] + for _id in params['id']: + if _id == libbe.diff.BUGDIR_ID: # directory-wide subscriptions type_root = libbe.diff.BUGDIR_TYPE_ALL entity = bugdir entity_name = 'bug directory' else: # bug-specific subscriptions type_root = libbe.diff.BUG_TYPE_ALL bug,dummy_comment = libbe.command.util.bug_comment_from_user_id( - bugdir, params['id']) + bugdir, _id) entity = bug entity_name = bug.id.user() if params['list-all'] == True: -- 2.26.2