Mercurial > python-cmd2
comparison cmd2.py @ 382:2687482dfa33
doubledashcomment moved into sqlpyPlus to define parser after local comment definition
author | catherine@Drou |
---|---|
date | Mon, 01 Mar 2010 23:26:55 -0500 |
parents | de2306847251 |
children | 2594f69698b2 |
comparison
equal
deleted
inserted
replaced
381:04897151927b | 382:2687482dfa33 |
---|---|
469 | 469 |
470 def __init__(self, *args, **kwargs): | 470 def __init__(self, *args, **kwargs): |
471 cmd.Cmd.__init__(self, *args, **kwargs) | 471 cmd.Cmd.__init__(self, *args, **kwargs) |
472 self.initial_stdout = sys.stdout | 472 self.initial_stdout = sys.stdout |
473 self.history = History() | 473 self.history = History() |
474 self._init_parser() | |
475 self.pystate = {} | 474 self.pystate = {} |
476 self.shortcuts = sorted(self.shortcuts.items(), reverse=True) | 475 self.shortcuts = sorted(self.shortcuts.items(), reverse=True) |
477 self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) | 476 self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) |
478 if fname.startswith('do_')] | 477 if fname.startswith('do_')] |
479 def linelist(arg): | 478 self._init_parser() |
480 result = [] | |
481 | |
482 self.doubleDashComment = pyparsing.NotAny(pyparsing.Or(options_defined)) + pyparsing.Literal('--') + pyparsing.restOfLine | |
483 | 479 |
484 def do_shortcuts(self, args): | 480 def do_shortcuts(self, args): |
485 """Lists single-key shortcuts available.""" | 481 """Lists single-key shortcuts available.""" |
486 result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in sorted(self.shortcuts)) | 482 result = "\n".join('%s: %s' % (sc[0], sc[1]) for sc in sorted(self.shortcuts)) |
487 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) | 483 self.stdout.write("Single-key shortcuts for other commands:\n%s\n" % (result)) |