# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1214272917 14400 # Node ID 824651b4d1b118ad9f1d7ae560863a8906509389 # Parent e06961ebd0353c8ef1ef6c43ad6d55de36079503 slash-endings working diff -r e06961ebd035 -r 824651b4d1b1 cmd2.py --- a/cmd2.py Mon Jun 23 20:52:41 2008 -0400 +++ b/cmd2.py Mon Jun 23 22:01:57 2008 -0400 @@ -128,6 +128,7 @@ raise OSError, pastebufferr % ('xclip', 'On Debian/Ubuntu, install with "sudo apt-get install xclip"') setPasteBuffer = getPasteBuffer +pyparsing.ParserElement.setDefaultWhitespaceChars(' \t') # see http://pyparsing.wikispaces.com/message/view/home/1352689 def punctuationParser(punctuators): """ Produces a string parser based on a list of targets to search for. @@ -137,7 +138,7 @@ >>> p('is terminated;') ('is terminated', [';'], '') >>> p('is terminated EOF after the end') - ('is terminated', ['EOF'], ' after the end') + ('is terminated', ['EOF'], 'after the end') >>> p('is not terminated') >>> pattern1 = pyparsing.Literal(';') + pyparsing.Optional(pyparsing.Word(pyparsing.nums)) >>> p2 = punctuationParser([pattern1, 'EOF']) @@ -164,7 +165,7 @@ class Cmd(cmd.Cmd): caseInsensitive = True - terminators = [';','\n'] + terminators = [';', pyparsing.LineEnd() + pyparsing.LineEnd()] multilineCommands = [] # commands that need a terminator to be finished terminatorKeepingCommands = [] # commands that expect to process their own terminators (else it will be stripped during parse) continuationPrompt = '> ' @@ -190,8 +191,8 @@ Commands may be terminated with: %(terminators)s Settable parameters: %(settable)s """ % - { 'casesensitive': ('not ' and self.caseInsensitive) or '', - 'terminators': ' '.join(str(self.terminators)), + { 'casesensitive': (self.caseInsensitive or '') and 'not ', + 'terminators': str(self.terminators), 'settable': ' '.join(self.settable) })