diff options
author | Eric Lin <anselor@gmail.com> | 2018-05-02 14:13:12 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-05-02 14:13:12 -0400 |
commit | 148f05d0af66f38c8ba6ca3a5619f50a8bb1b8a9 (patch) | |
tree | 10513021d2932b205375e444c2f51a104cebbbc1 | |
parent | 8d8db3f31b40c39cae43ec3d2bda0ea0c258b3db (diff) | |
download | cmd2-git-148f05d0af66f38c8ba6ca3a5619f50a8bb1b8a9.tar.gz |
Addressed comments.
-rw-r--r-- | cmd2/__init__.py | 2 | ||||
-rw-r--r-- | cmd2/argcomplete_bridge.py | 14 | ||||
-rwxr-xr-x | examples/alias_startup.py | 4 | ||||
-rwxr-xr-x | examples/help_categories.py | 3 |
4 files changed, 8 insertions, 15 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py index d3d193cf..bf6c047f 100644 --- a/cmd2/__init__.py +++ b/cmd2/__init__.py @@ -1,4 +1,2 @@ # # -*- coding: utf-8 -*- - - diff --git a/cmd2/argcomplete_bridge.py b/cmd2/argcomplete_bridge.py index 5383ebec..583f3345 100644 --- a/cmd2/argcomplete_bridge.py +++ b/cmd2/argcomplete_bridge.py @@ -148,16 +148,15 @@ else: # not an argument completion invocation return - global debug_stream try: - debug_stream = os.fdopen(9, "w") - except: - debug_stream = sys.stderr + argcomplete.debug_stream = os.fdopen(9, "w") + except IOError: + argcomplete.debug_stream = sys.stderr if output_stream is None: try: output_stream = os.fdopen(8, "wb") - except: + except IOError: argcomplete.debug("Unable to open fd 8 for writing, quitting") exit_method(1) @@ -234,7 +233,7 @@ else: # to ever match. outstr = outstr.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ').strip() # generate a filler entry that should always sort first - filler = ' {0:><{width}}'.format('', width=len(outstr)) + filler = ' {0:><{width}}'.format('', width=len(outstr)/2) outstr = ifs.join([filler, outstr]) output_stream.write(outstr.encode(argcomplete.sys_encoding)) @@ -243,6 +242,5 @@ else: # go forward with normal filesystem completion output_stream.write(ifs.join([]).encode(argcomplete.sys_encoding)) output_stream.flush() - debug_stream.flush() + argcomplete.debug_stream.flush() exit_method(0) - diff --git a/examples/alias_startup.py b/examples/alias_startup.py index a02972b6..7ccfa6e5 100755 --- a/examples/alias_startup.py +++ b/examples/alias_startup.py @@ -4,12 +4,8 @@ 1) How to add custom command aliases using the alias command 2) How to load an initialization script at startup """ -import argparse from cmd2 import cmd2 -import pyparsing - -from cmd2.cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args class AliasAndStartup(cmd2.Cmd): diff --git a/examples/help_categories.py b/examples/help_categories.py index 7adedb51..dcfbd31f 100755 --- a/examples/help_categories.py +++ b/examples/help_categories.py @@ -4,9 +4,10 @@ A sample application for tagging categories on commands. """ -from cmd2.cmd2 import Cmd, categorize, __version__, with_argparser, with_category import argparse +from cmd2.cmd2 import Cmd, categorize, __version__, with_argparser, with_category + class HelpCategories(Cmd): """ Example cmd2 application. """ |