comparison cmd2.py @ 292:23cf05c6276c

time to work on parsing refactor
author catherine@bothari
date Thu, 21 Jan 2010 19:59:28 -0500
parents dfdbd93a2fae
children bbc339f3ddeb
comparison
equal deleted inserted replaced
291:dfdbd93a2fae 292:23cf05c6276c
626 626
627 def parsed(self, raw, **kwargs): 627 def parsed(self, raw, **kwargs):
628 if isinstance(raw, ParsedString): 628 if isinstance(raw, ParsedString):
629 p = raw 629 p = raw
630 else: 630 else:
631 # preparse is an overridable hook; default makes no changes
631 raw = self.preparse(raw, **kwargs) 632 raw = self.preparse(raw, **kwargs)
632 s = self.inputParser.transformString(raw.lstrip()) 633 s = self.inputParser.transformString(raw.lstrip())
633 for (shortcut, expansion) in self.shortcuts: 634 for (shortcut, expansion) in self.shortcuts:
634 if s.lower().startswith(shortcut): 635 if s.lower().startswith(shortcut):
635 s = s.replace(shortcut, expansion + ' ', 1) 636 s = s.replace(shortcut, expansion + ' ', 1)
723 self.stdout = tempfile.TemporaryFile() 724 self.stdout = tempfile.TemporaryFile()
724 if statement.parsed.output == '>>': 725 if statement.parsed.output == '>>':
725 self.stdout.write(get_paste_buffer()) 726 self.stdout.write(get_paste_buffer())
726 try: 727 try:
727 try: 728 try:
728 # "heart" of the command, replace's cmd's onecmd() 729 # "heart" of the command, replaces cmd's onecmd()
729 self.lastcmd = statement.parsed.expanded 730 self.lastcmd = statement.parsed.expanded
730 funcname = self.func_named(statement.parsed.command) 731 funcname = self.func_named(statement.parsed.command)
731 if not funcname: 732 if not funcname:
732 return self.postparsing_postcmd(self.default(statement)) 733 return self.postparsing_postcmd(self.default(statement))
733 try: 734 try: