libbe.command.subscribe

class libbe.command.subscribe.Subscribe(*args, **kwargs)

(Un)subscribe to change notification

>>> import sys
>>> import libbe.bugdir
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> io = libbe.command.StringInputOutput()
>>> io.stdout = sys.stdout
>>> ui = libbe.command.UserInterface(io=io)
>>> ui.storage_callbacks.set_storage(bd.storage)
>>> cmd = Subscribe(ui=ui)
>>> a = bd.bug_from_uuid('a')
>>> print a.extra_strings
[]
>>> ret = ui.run(cmd, {'subscriber':'John Doe <j@doe.com>'}, ['/a']) 
Subscriptions for abc/a:
John Doe <j@doe.com>    all    *
>>> bd.flush_reload()
>>> a = bd.bug_from_uuid('a')
>>> print a.extra_strings
['SUBSCRIBE:John Doe <j@doe.com>\tall\t*']
>>> ret = ui.run(cmd, {'subscriber':'Jane Doe <J@doe.com>', 'servers':'a.com,b.net'}, ['/a']) 
Subscriptions for abc/a:
Jane Doe <J@doe.com>    all    a.com,b.net
John Doe <j@doe.com>    all    *
>>> ret = ui.run(cmd, {'subscriber':'Jane Doe <J@doe.com>', 'servers':'a.edu'}, ['/a']) 
Subscriptions for abc/a:
Jane Doe <J@doe.com>    all    a.com,a.edu,b.net
John Doe <j@doe.com>    all    *
>>> ret = ui.run(cmd, {'unsubscribe':True, 'subscriber':'Jane Doe <J@doe.com>', 'servers':'a.com'}, ['/a']) 
Subscriptions for abc/a:
Jane Doe <J@doe.com>    all    a.edu,b.net
John Doe <j@doe.com>    all    *
>>> ret = ui.run(cmd, {'subscriber':'Jane Doe <J@doe.com>', 'servers':'*'}, ['/a']) 
Subscriptions for abc/a:
Jane Doe <J@doe.com>    all    *
John Doe <j@doe.com>    all    *
>>> ret = ui.run(cmd, {'unsubscribe':True, 'subscriber':'Jane Doe <J@doe.com>'}, ['/a']) 
Subscriptions for abc/a:
John Doe <j@doe.com>    all    *
>>> ret = ui.run(cmd, {'unsubscribe':True, 'subscriber':'John Doe <j@doe.com>'}, ['/a'])
>>> ret = ui.run(cmd,
...     {'subscriber':'Jane Doe <J@doe.com>', 'types':'new'},
...     [bd.uuid[:3]]) 
Subscriptions for abc:
Jane Doe <J@doe.com>    new    *
>>> ret = ui.run(cmd,
...     {'subscriber':'Jane Doe <J@doe.com>'},
...     [bd.uuid]) 
Subscriptions for abc:
Jane Doe <J@doe.com>    all    *
>>> ui.cleanup()
>>> bd.cleanup()

Methods

cleanup()
complete([argument, fragment])
help(*args)
run([options, args])
usage()
name = 'subscribe'
libbe.command.subscribe.get_bugdir_subscribers(bugdir, server)
libbe.command.subscribe.get_subscribers(extra_strings, type, server, type_root, match_ancestor_types=False, match_descendant_types=False)

Set match_ancestor_types=True if you want to find eveyone who cares about your particular type.

Set match_descendant_types=True if you want to find subscribers who may only care about some subset of your type. This is useful for generating lists of all the subscribers in a given set of extra_strings.

>>> def sgs(*args, **kwargs):
...     return sorted(get_subscribers(*args, **kwargs))
>>> es = []
>>> es = subscribe(es, "John Doe <j@doe.com>", [libbe.diff.BUGDIR_TYPE_ALL],
...                ["a.com"], libbe.diff.BUGDIR_TYPE_ALL)
>>> es = subscribe(es, "Jane Doe <J@doe.com>", [libbe.diff.BUGDIR_TYPE_NEW],
...                ["*"], libbe.diff.BUGDIR_TYPE_ALL)
>>> sgs(es, libbe.diff.BUGDIR_TYPE_ALL, "a.com", libbe.diff.BUGDIR_TYPE_ALL)
['John Doe <j@doe.com>']
>>> sgs(es, libbe.diff.BUGDIR_TYPE_ALL, "a.com", libbe.diff.BUGDIR_TYPE_ALL,
...     match_descendant_types=True)
['Jane Doe <J@doe.com>', 'John Doe <j@doe.com>']
>>> sgs(es, libbe.diff.BUGDIR_TYPE_ALL, "b.net", libbe.diff.BUGDIR_TYPE_ALL,
...     match_descendant_types=True)
['Jane Doe <J@doe.com>']
>>> sgs(es, libbe.diff.BUGDIR_TYPE_NEW, "a.com", libbe.diff.BUGDIR_TYPE_ALL)
['Jane Doe <J@doe.com>']
>>> sgs(es, libbe.diff.BUGDIR_TYPE_NEW, "a.com", libbe.diff.BUGDIR_TYPE_ALL,
... match_ancestor_types=True)
['Jane Doe <J@doe.com>', 'John Doe <j@doe.com>']
libbe.command.subscribe.subscribe(extra_strings, subscriber, types, servers, type_root)
libbe.command.subscribe.unsubscribe(extra_strings, subscriber, types, servers, type_root)

This Page