Mercurial > python-cmd2
comparison cmd2.py @ 248:575652efb3d8
aha - I think I know why comment-in-progress parse failing
author | catherine@Elli.myhome.westell.com |
---|---|
date | Mon, 30 Mar 2009 12:56:08 -0400 |
parents | 3db4166a54ce |
children | 55a12d77a4fa |
comparison
equal
deleted
inserted
replaced
247:3db4166a54ce | 248:575652efb3d8 |
---|---|
27 """ | 27 """ |
28 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest | 28 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest |
29 import unittest, string, datetime, urllib | 29 import unittest, string, datetime, urllib |
30 from code import InteractiveConsole, InteractiveInterpreter, softspace | 30 from code import InteractiveConsole, InteractiveInterpreter, softspace |
31 from optparse import make_option | 31 from optparse import make_option |
32 __version__ = '0.5.0' | 32 __version__ = '0.5.1' |
33 | 33 |
34 class OptionParser(optparse.OptionParser): | 34 class OptionParser(optparse.OptionParser): |
35 def exit(self, status=0, msg=None): | 35 def exit(self, status=0, msg=None): |
36 self.values._exit = True | 36 self.values._exit = True |
37 if msg: | 37 if msg: |
504 self.blankLineTerminationParser = ((self.multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(self.blankLineTerminator).setParseAction(lambda x: x[0].strip())('args') + self.blankLineTerminator)('statement') | 504 self.blankLineTerminationParser = ((self.multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(self.blankLineTerminator).setParseAction(lambda x: x[0].strip())('args') + self.blankLineTerminator)('statement') |
505 self.multilineParser = (((self.multilineCommand ^ oneLineCommand) + SkipToLast(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') + | 505 self.multilineParser = (((self.multilineCommand ^ oneLineCommand) + SkipToLast(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') + |
506 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements) | 506 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements) |
507 self.singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + | 507 self.singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + |
508 pyparsing.Optional(terminatorParser) + afterElements) | 508 pyparsing.Optional(terminatorParser) + afterElements) |
509 #self.multilineParser = self.multilineParser.setResultsName('multilineParser') | 509 self.multilineParser = self.multilineParser.setResultsName('multilineParser') |
510 #self.singleLineParser = self.singleLineParser.setResultsName('singleLineParser') | 510 self.singleLineParser = self.singleLineParser.setResultsName('singleLineParser') |
511 #self.blankLineTerminationParser = self.blankLineTerminationParser.setResultsName('blankLineTerminatorParser') | 511 self.blankLineTerminationParser = self.blankLineTerminationParser.setResultsName('blankLineTerminatorParser') |
512 self.parser = ( | 512 self.parser = ( |
513 stringEnd | | 513 stringEnd | |
514 self.prefixParser + self.multilineParser | | 514 self.prefixParser + self.multilineParser | |
515 self.prefixParser + self.singleLineParser | | 515 self.prefixParser + self.singleLineParser | |
516 self.prefixParser + self.blankLineTerminationParser | | 516 self.prefixParser + self.blankLineTerminationParser | |