Mercurial > python-cmd2
comparison cmd2.py @ 182:1c21db096f49
switched literal newline to lineEnd
author | catherine@Elli.myhome.westell.com |
---|---|
date | Thu, 15 Jan 2009 19:38:07 -0500 |
parents | 24eff658997b |
children | 403e1c3ffc4a |
comparison
equal
deleted
inserted
replaced
181:24eff658997b | 182:1c21db096f49 |
---|---|
388 multilineCommand.setParseAction(lambda x: x[0].lower()) | 388 multilineCommand.setParseAction(lambda x: x[0].lower()) |
389 oneLineCommand.setParseAction(lambda x: x[0].lower()) | 389 oneLineCommand.setParseAction(lambda x: x[0].lower()) |
390 if self.blankLinesAllowed: | 390 if self.blankLinesAllowed: |
391 blankLineTerminationParser = pyparsing.NoMatch | 391 blankLineTerminationParser = pyparsing.NoMatch |
392 else: | 392 else: |
393 blankLineTerminator = (pyparsing.Literal('\n')('terminator') + stringEnd) | 393 blankLineTerminator = (pyparsing.lineEnd('terminator') + stringEnd) |
394 blankLineTerminationParser = ((multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(blankLineTerminator).setParseAction(lambda x: x[0].strip())('args') + blankLineTerminator)('statement') | 394 blankLineTerminationParser = ((multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(blankLineTerminator).setParseAction(lambda x: x[0].strip())('args') + blankLineTerminator)('statement') |
395 multilineParser = (((multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') + | 395 multilineParser = (((multilineCommand ^ oneLineCommand) + pyparsing.SkipTo(terminatorParser).setParseAction(lambda x: x[0].strip())('args') + terminatorParser)('statement') + |
396 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements) | 396 pyparsing.SkipTo(outputParser ^ pipe ^ stringEnd).setParseAction(lambda x: x[0].strip())('suffix') + afterElements) |
397 singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + | 397 singleLineParser = ((oneLineCommand + pyparsing.SkipTo(terminatorParser ^ stringEnd ^ pipe ^ outputParser).setParseAction(lambda x:x[0].strip())('args'))('statement') + |
398 pyparsing.Optional(terminatorParser) + afterElements) | 398 pyparsing.Optional(terminatorParser) + afterElements) |
399 self.parser = ( | 399 self.parser = ( |
400 stringEnd | | 400 stringEnd | |
401 multilineParser | | 401 multilineParser | |
402 multilineCommand + pyparsing.SkipTo(stringEnd) | | 402 multilineCommand + pyparsing.SkipTo(stringEnd) | |
403 singleLineParser | | 403 singleLineParser | |
613 val = cast(currentVal, val) | 613 val = cast(currentVal, val) |
614 setattr(self, paramName, val) | 614 setattr(self, paramName, val) |
615 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) | 615 self.stdout.write('%s - was: %s\nnow: %s\n' % (paramName, currentVal, val)) |
616 except (ValueError, AttributeError, NotSettableError), e: | 616 except (ValueError, AttributeError, NotSettableError), e: |
617 self.do_show(arg) | 617 self.do_show(arg) |
618 do_set.__doc__ = '%s\nOne of: %s' % (do_set.__doc__, ', '.join(settable)) | |
618 | 619 |
620 def do_pause(self, arg): | |
621 'Displays the specified text then waits for the user to press RETURN.' | |
622 raw_input(arg + '\n') | |
623 | |
619 def do_shell(self, arg): | 624 def do_shell(self, arg): |
620 'execute a command as if at the OS prompt.' | 625 'execute a command as if at the OS prompt.' |
621 os.system(arg) | 626 os.system(arg) |
622 | 627 |
623 def do_history(self, arg): | 628 def do_history(self, arg): |