Mercurial > python-cmd2
changeset 286:3c4ba65cb303
sprucing up comments
author | catherine@bothari |
---|---|
date | Fri, 16 Oct 2009 17:52:47 -0400 |
parents | 58be960b8bf9 |
children | 1cd23003e8d5 |
files | cmd2.py |
diffstat | 1 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd2.py Thu Oct 15 19:03:29 2009 -0400 +++ b/cmd2.py Fri Oct 16 17:52:47 2009 -0400 @@ -35,7 +35,6 @@ print msg def print_help(self, *args, **kwargs): - # now, I need to call help of the calling function. Hmm. try: print self._func.__doc__ except AttributeError: @@ -65,7 +64,9 @@ def _attr_get_(obj, attr): '''Returns an attribute's value, or None (no error) if undefined. - Analagous to .get() for dictionaries.''' + Analagous to .get() for dictionaries. Useful when checking for + value of options that may not have been defined on a given + method.''' try: return getattr(obj, attr) except AttributeError: @@ -86,12 +87,12 @@ args = arg.parsed.raw else: args = arg - opts, newArgList = optionParser.parse_args(args.split()) # doesn't understand quoted strings shouldn't be dissected! + opts, newArgList = optionParser.parse_args(args.split()) # Must find the remaining args in the original argument list, but # mustn't include the command itself if hasattr(arg, 'parsed') and newArgList[0] == arg.parsed.command: newArgList = newArgList[1:] - newArgs = remainingArgs(args, newArgList) # should it permit flags after args? + newArgs = remainingArgs(args, newArgList) except (optparse.OptionValueError, optparse.BadOptionError, optparse.OptionError, optparse.AmbiguousOptionError, optparse.OptionConflictError), e: @@ -129,10 +130,10 @@ def __init__(self): Exception.__init__(self, self.errmsg) -'''check here if functions exist; otherwise, stub out''' pastebufferr = """Redirecting to or from paste buffer requires %s to be installed on operating system. %s""" + if subprocess.mswindows: try: import win32clipboard @@ -271,15 +272,16 @@ class Cmd(cmd.Cmd): echo = False - case_insensitive = True + case_insensitive = True # Commands recognized regardless of case continuation_prompt = '> ' - timing = False - legalChars = '!#$%.:?@_' + pyparsing.alphanums + pyparsing.alphas8bit # make sure your terminators are not in here! + timing = False # Prints elapsed time for each command + # make sure your terminators are not in legalChars! + legalChars = '!#$%.:?@_' + pyparsing.alphanums + pyparsing.alphas8bit shortcuts = {'?': 'help', '!': 'shell', '@': 'load', '@@': '_relative_load'} excludeFromHistory = '''run r list l history hi ed edit li eof'''.split() noSpecialParse = 'set ed edit exit'.split() - defaultExtension = 'txt' - default_file_name = 'command.txt' + defaultExtension = 'txt' # For ``save``, ``load``, etc. + default_file_name = 'command.txt' # For ``save``, ``load``, etc. abbrev = True nonpythoncommand = 'cmd' current_script_dir = None @@ -1239,4 +1241,4 @@ unittest.main() else: CmdLineApp().cmdloop() -''' \ No newline at end of file +'''