diff options
author | W. Trevor King <wking@drexel.edu> | 2008-11-25 15:47:19 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-11-25 15:47:19 -0500 |
commit | 5699aef2a5741c5ffc24d9cb12d6bc9b085d484a (patch) | |
tree | 84ac8783ce2d1f9a28ba0bd0c256ae7179c68507 /becommands/set_root.py | |
parent | ed4d971d1375a692fbd3a394237f56e851bb5d0e (diff) | |
download | bugseverywhere-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/set_root.py')
-rw-r--r-- | becommands/set_root.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/becommands/set_root.py b/becommands/set_root.py index e17bd87..11f38b9 100644 --- a/becommands/set_root.py +++ b/becommands/set_root.py @@ -19,7 +19,7 @@ import os.path from libbe import cmdutil, bugdir __desc__ = __doc__ -def execute(args): +def execute(args, test=False): """ >>> from libbe import utility, rcs >>> import os @@ -29,7 +29,7 @@ def execute(args): ... except bugdir.NoBugDir, e: ... True True - >>> execute([dir.path]) + >>> execute([dir.path], test=True) No revision control detected. Directory initialized. >>> del(dir) @@ -40,34 +40,31 @@ def execute(args): >>> rcs.init('.') >>> print rcs.name Arch - >>> execute([]) + >>> execute([], test=True) Using Arch for revision control. Directory initialized. >>> rcs.cleanup() >>> try: - ... execute(['.']) + ... execute(['.'], test=True) ... except cmdutil.UserError, e: ... str(e).startswith("Directory already initialized: ") True - >>> execute(['/highly-unlikely-to-exist']) + >>> execute(['/highly-unlikely-to-exist'], test=True) Traceback (most recent call last): UserError: No such directory: /highly-unlikely-to-exist >>> os.chdir('/') """ options, args = get_parser().parse_args(args) if len(args) > 1: - print help() - raise cmdutil.UserError, "Too many arguments" + raise cmdutil.UsageError if len(args) == 1: basedir = args[0] else: basedir = "." - if os.path.exists(basedir) == False: - pass - #raise cmdutil.UserError, "No such directory: %s" % basedir try: - bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True) + bd = bugdir.BugDir(basedir, from_disk=False, sink_to_existing_root=False, assert_new_BugDir=True, + manipulate_encodings=not test) except bugdir.NoRootEntry: raise cmdutil.UserError("No such directory: %s" % basedir) except bugdir.AlreadyInitialized: |