changeset 162:c50615cf814f

merged with changes from work
author catherine@Elli.myhome.westell.com
date Tue, 02 Dec 2008 11:00:41 -0500
parents 1d1439be0a55
children 61a57c44cd93
files cmd2.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Mon Dec 01 16:26:28 2008 -0500
+++ b/cmd2.py	Tue Dec 02 11:00:41 2008 -0500
@@ -52,7 +52,7 @@
         def newFunc(instance, arg):
             try:
                 opts, newArgs = optionParser.parse_args(arg.split())
-                newArgs = arg[arg.find(newArgs[0]):]
+                newArgs = (newArgs and arg[arg.find(newArgs[0]):]) or ''
             except (optparse.OptionValueError, optparse.BadOptionError,
                     optparse.OptionError, optparse.AmbiguousOptionError,
                     optparse.OptionConflictError), e:
@@ -406,6 +406,11 @@
         self.inputParser.ignore(pyparsing.sglQuotedString).ignore(pyparsing.dblQuotedString).ignore(self.commentGrammars).ignore(self.commentInProgress)               
     
     def parsed(self, raw, useTerminatorFrom=None):
+        if isinstance(raw, ParsedString):
+            if useTerminatorFrom:
+                raw['terminator'] = useTerminatorFrom.parsed.terminator
+                raw['suffix'] = useTerminatorFrom.parsed.suffix
+            return raw           
         s = self.inputParser.transformString(raw.strip())
         for (shortcut, expansion) in self.shortcuts.items():
             if s.startswith(shortcut):
@@ -413,9 +418,7 @@
                 break
         result = self.parser.parseString(s)
         result['command'] = result.multilineCommand or result.command
-        #result['statement'] = ' '.join(result.statement)
         result['raw'] = raw
-        #result['clean'] = self.commentGrammars.transformString(result.statement)
         result['clean'] = self.commentGrammars.transformString(result.args)
         result['expanded'] = s
         if useTerminatorFrom: