aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/target.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2008-11-25 15:47:19 -0500
committerW. Trevor King <wking@drexel.edu>2008-11-25 15:47:19 -0500
commit5699aef2a5741c5ffc24d9cb12d6bc9b085d484a (patch)
tree84ac8783ce2d1f9a28ba0bd0c256ae7179c68507 /becommands/target.py
parented4d971d1375a692fbd3a394237f56e851bb5d0e (diff)
downloadbugseverywhere-5699aef2a5741c5ffc24d9cb12d6bc9b085d484a.tar.gz
Added libbe/encoding.py to wrap input/output/file access appropriately.
I borrowed most of the code for this. get_encoding() is from Trac http://trac.edgewall.org/browser/trunk/trac/util/datefmt.py format_datetime() Trac has a BSD license http://trac.edgewall.org/wiki/TracLicense I don't know if such a small snippet requires us to "reproduce the above copyright" or where we need to reproduce it if it is needed. The stdout/stdin replacement code follows http://wiki.python.org/moin/ShellRedirectionFails Because of the stdout replacement, the doctests executes now need an optional 'test' argument to turn off replacement during the doctests, otherwise doctest flips out (since it had set up stdout to catch output, and then we clobbered it's setup). References: http://wiki.python.org/moin/Unicode http://www.amk.ca/python/howto/unicode http://www.python.org/dev/peps/pep-0100/ I also split libbe/editor.py off from libbe.utility.py and started explaining the motivation for the BugDir init flags in it's docstring.
Diffstat (limited to 'becommands/target.py')
-rw-r--r--becommands/target.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/becommands/target.py b/becommands/target.py
index dce100f..4371ef0 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -18,33 +18,32 @@
from libbe import cmdutil, bugdir
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute(["a"])
+ >>> execute(["a"], test=True)
No target assigned.
- >>> execute(["a", "tomorrow"])
- >>> execute(["a"])
+ >>> execute(["a", "tomorrow"], test=True)
+ >>> execute(["a"], test=True)
tomorrow
- >>> execute(["a", "none"])
- >>> execute(["a"])
+ >>> execute(["a", "none"], test=True)
+ >>> execute(["a"], test=True)
No target assigned.
"""
options, args = get_parser().parse_args(args)
- assert(len(args) in (0, 1, 2))
- if len(args) == 0:
- print help()
- return
- bd = bugdir.BugDir(from_disk=True)
+ if len(args) not in (1, 2):
+ raise cmdutil.UsageError
+ 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:
print "No target assigned."
else:
print bug.target
- elif len(args) == 2:
+ else:
+ assert len(args) == 2
if args[1] == "none":
bug.target = None
else: