diff options
author | W. Trevor King <wking@drexel.edu> | 2009-12-14 23:15:58 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-12-14 23:15:58 -0500 |
commit | 1b9c628529848af370adbc67b5ba298236a1b86d (patch) | |
tree | dd16c447d971297637b59128c383c942a5578d1e /libbe/command/new.py | |
parent | 0786fc6693e40cdfaca7876b504acb3e5e7dc4d2 (diff) | |
download | bugseverywhere-1b9c628529848af370adbc67b5ba298236a1b86d.tar.gz |
Transitioned severity to Command-format, also added Command._get_*()
The old
.requires_*
thing was rediculous. The new ._get_*() callbacks allow the caller
to provide a means for getting the expensive structures, which the
command can use, or not, as required. This will also make it easier
to implement the completion callbacks.
The callbacks should probably have matching .set_*() methods, to
avoid the current cache tweaking
cmd._storage = ...
etc. But that can wait for now...
Diffstat (limited to 'libbe/command/new.py')
-rw-r--r-- | libbe/command/new.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libbe/command/new.py b/libbe/command/new.py index d840503..de215fa 100644 --- a/libbe/command/new.py +++ b/libbe/command/new.py @@ -31,11 +31,12 @@ class New (libbe.command.Command): >>> import libbe.util.id >>> bd = libbe.bugdir.SimpleBugDir(memory=False) >>> cmd = New() + >>> cmd._storage = bd.storage >>> cmd._setup_io = lambda i_enc,o_enc : None >>> cmd.stdout = sys.stdout >>> libbe.util.id.uuid_gen = lambda: 'X' - >>> ret = cmd.run(bd.storage, bd, args=['this is a test',]) + >>> ret = cmd.run(args=['this is a test',]) Created bug with ID abc/X >>> bd.flush_reload() >>> bug = bd.bug_from_uuid('X') @@ -53,7 +54,6 @@ class New (libbe.command.Command): def __init__(self, *args, **kwargs): libbe.command.Command.__init__(self, *args, **kwargs) - self.requires_bugdir = True self.options.extend([ libbe.command.Option(name='reporter', short_name='r', help='The user who reported the bug', @@ -69,11 +69,12 @@ class New (libbe.command.Command): libbe.command.Argument(name='summary', metavar='SUMMARY') ]) - def _run(self, storage, bugdir, **params): + def _run(self, **params): if params['summary'] == '-': # read summary from stdin summary = self.stdin.readline() else: summary = params['summary'] + bugdir = self._get_bugdir() bug = bugdir.new_bug(summary=summary.strip()) if params['reporter'] != None: bug.reporter = params['reporter'] |