diff options
author | W. Trevor King <wking@drexel.edu> | 2008-12-02 19:11:56 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-12-02 19:11:56 -0500 |
commit | 404a76f0d49e36b7cc475928d7d665a56d83cadb (patch) | |
tree | 4dbd7ffa443fa3464fb80914a75a15438167e9c4 /becommands | |
parent | 0f81920080f550af3c8df6fc1d16e57cc7f432e1 (diff) | |
parent | 0f9429a25175007fe0291814dc25e088983abbfa (diff) | |
download | bugseverywhere-404a76f0d49e36b7cc475928d7d665a56d83cadb.tar.gz |
Merged decorator branch.
Diffstat (limited to 'becommands')
-rw-r--r-- | becommands/assign.py | 6 | ||||
-rw-r--r-- | becommands/comment.py | 12 | ||||
-rw-r--r-- | becommands/new.py | 4 | ||||
-rw-r--r-- | becommands/set.py | 45 | ||||
-rw-r--r-- | becommands/target.py | 4 |
5 files changed, 46 insertions, 25 deletions
diff --git a/becommands/assign.py b/becommands/assign.py index a41bbae..2f9ff21 100644 --- a/becommands/assign.py +++ b/becommands/assign.py @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Assign an individual or group to fix a bug""" -from libbe import cmdutil, bugdir +from libbe import cmdutil, bugdir, settings_object __desc__ = __doc__ def execute(args, test=False): @@ -23,7 +23,7 @@ def execute(args, test=False): >>> import os >>> bd = bugdir.simple_bug_dir() >>> os.chdir(bd.root) - >>> bd.bug_from_shortname("a").assigned is None + >>> bd.bug_from_shortname("a").assigned is settings_object.EMPTY True >>> execute(["a"], test=True) @@ -38,7 +38,7 @@ def execute(args, test=False): >>> execute(["a","none"], test=True) >>> bd._clear_bugs() - >>> bd.bug_from_shortname("a").assigned is None + >>> bd.bug_from_shortname("a").assigned is settings_object.EMPTY True """ parser = get_parser() diff --git a/becommands/comment.py b/becommands/comment.py index 5000588..b15a06e 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Add a comment to a bug""" -from libbe import cmdutil, bugdir, editor +from libbe import cmdutil, bugdir, settings_object, editor import os __desc__ = __doc__ @@ -27,7 +27,7 @@ def execute(args, test=False): >>> execute(["a", "This is a comment about a"], test=True) >>> bd._clear_bugs() >>> bug = bd.bug_from_shortname("a") - >>> bug.load_comments() + >>> bug.load_comments(load_full=False) >>> comment = bug.comment_root[0] >>> print comment.body This is a comment about a @@ -36,7 +36,7 @@ def execute(args, test=False): True >>> comment.time <= int(time.time()) True - >>> comment.in_reply_to is None + >>> comment.in_reply_to is settings_object.EMPTY True >>> if 'EDITOR' in os.environ: @@ -49,7 +49,7 @@ def execute(args, test=False): >>> execute(["b"], test=True) >>> bd._clear_bugs() >>> bug = bd.bug_from_shortname("b") - >>> bug.load_comments() + >>> bug.load_comments(load_full=False) >>> comment = bug.comment_root[0] >>> print comment.body I like cheese @@ -76,7 +76,7 @@ def execute(args, test=False): bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) bug = bd.bug_from_shortname(bugname) - bug.load_comments() + bug.load_comments(load_full=False) if is_reply: parent = bug.comment_root.comment_from_shortname(shortname, bug_shortname=bugname) @@ -139,7 +139,7 @@ def complete(options, args, parser): for bug in bugs: shortname = bd.bug_shortname(bug) ids.append(shortname) - bug.load_comments() + bug.load_comments(load_full=False) for id,comment in bug.comment_shortnames(shortname): ids.append(id) except bugdir.NoBugDir: diff --git a/becommands/new.py b/becommands/new.py index 58fabbc..69ff5b8 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Create a new bug""" -from libbe import cmdutil, bugdir +from libbe import cmdutil, bugdir, settings_object __desc__ = __doc__ def execute(args, test=False): @@ -35,7 +35,7 @@ def execute(args, test=False): True >>> bug.severity u'minor' - >>> bug.target == None + >>> bug.target == settings_object.EMPTY True """ parser = get_parser() diff --git a/becommands/set.py b/becommands/set.py index aef5eb3..b8a125e 100644 --- a/becommands/set.py +++ b/becommands/set.py @@ -15,9 +15,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Change tree settings""" -from libbe import cmdutil, bugdir +from libbe import cmdutil, bugdir, settings_object __desc__ = __doc__ +def _value_string(bd, setting): + val = bd.settings.get(setting, settings_object.EMPTY) + if val == settings_object.EMPTY: + default = getattr(bd, bd._setting_name_to_attr_name(setting)) + if default != settings_object.EMPTY: + val = "None (%s)" % default + else: + val = None + return str(val) + def execute(args, test=False): """ >>> import os @@ -34,28 +44,27 @@ def execute(args, test=False): """ parser = get_parser() options, args = parser.parse_args(args) - cmdutil.default_complete(options, args, parser) + complete(options, args, parser) if len(args) > 2: raise cmdutil.UsageError, "Too many arguments" bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) if len(args) == 0: - keys = bd.settings.keys() + keys = bd.settings_properties keys.sort() for key in keys: - print "%16s: %s" % (key, bd.settings[key]) + print "%16s: %s" % (key, _value_string(bd, key)) elif len(args) == 1: - print bd.settings.get(args[0]) + print _value_string(bd, args[0]) else: if args[1] != "none": + if args[0] not in bd.settings_properties: + msg = "Invalid setting %s\n" % args[0] + msg += 'Allowed settings:\n ' + msg += '\n '.join(bd.settings_properties) + raise cmdutil.UserError(msg) old_setting = bd.settings.get(args[0]) - bd.settings[args[0]] = args[1] - if args[0] == "user_id": - bd.save_user_id() - - # attempt to get the new value - bd.save() try: - bd.load() + setattr(bd, args[0], args[1]) except bugdir.InvalidValue, e: bd.settings[args[0]] = old_setting bd.save() @@ -86,3 +95,15 @@ To unset a setting, set it to "none". def help(): return get_parser().help_str() + longhelp + +def complete(options, args, parser): + for option, value in cmdutil.option_value_pairs(options, parser): + if value == "--complete": + # no argument-options at the moment, so this is future-proofing + raise cmdutil.GetCompletions() + for pos,value in enumerate(args): + if value == "--complete": + if pos == 0: # first positional argument is a setting name + props = bugdir.BugDir.settings_properties + raise cmdutil.GetCompletions(props) + raise cmdutil.GetCompletions() # no positional arguments for list diff --git a/becommands/target.py b/becommands/target.py index d14ff06..c83ffa7 100644 --- a/becommands/target.py +++ b/becommands/target.py @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's target for fixing""" -from libbe import cmdutil, bugdir +from libbe import cmdutil, bugdir, settings_object __desc__ = __doc__ def execute(args, test=False): @@ -41,7 +41,7 @@ def execute(args, test=False): bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) bug = bd.bug_from_shortname(args[0]) if len(args) == 1: - if bug.target is None: + if bug.target is None or bug.target is settings_object.EMPTY: print "No target assigned." else: print bug.target |