comparison cmd2.py @ 353:5e3f918c41d8

fixed bug in empty values
author catherine@Drou
date Wed, 17 Feb 2010 00:01:55 -0500
parents 1c91655d05f8
children 7cd04727f7f7
comparison
equal deleted inserted replaced
352:798c7f32a960 353:5e3f918c41d8
747 result = 'do_' + funcs[0] 747 result = 'do_' + funcs[0]
748 return result 748 return result
749 def onecmd_plus_hooks(self, line): 749 def onecmd_plus_hooks(self, line):
750 stop = 0 750 stop = 0
751 try: 751 try:
752 try: 752 statement = self.complete_statement(line)
753 statement = self.complete_statement(line)
754 except EmptyStatement:
755 return 0
756 (stop, statement) = self.postparsing_precmd(statement) 753 (stop, statement) = self.postparsing_precmd(statement)
757 if stop: 754 if stop:
758 return self.postparsing_postcmd(stop) 755 return self.postparsing_postcmd(stop)
759 if statement.parsed.command not in self.excludeFromHistory: 756 if statement.parsed.command not in self.excludeFromHistory:
760 self.history.append(statement.parsed.raw) 757 self.history.append(statement.parsed.raw)
761 self.redirect_output(statement) 758 try:
762 timestart = datetime.datetime.now() 759 self.redirect_output(statement)
763 statement = self.precmd(statement) 760 timestart = datetime.datetime.now()
764 stop = self.onecmd(statement) 761 statement = self.precmd(statement)
765 stop = self.postcmd(stop, statement) 762 stop = self.onecmd(statement)
766 if self.timing: 763 stop = self.postcmd(stop, statement)
767 self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart)) 764 if self.timing:
765 self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart))
766 finally:
767 self.restore_output(statement)
768 except EmptyStatement:
769 return 0
768 except Exception, e: 770 except Exception, e:
769 self.perror(str(e), statement) 771 self.perror(str(e), statement)
770 finally: 772 finally:
771 self.restore_output(statement)
772 return self.postparsing_postcmd(stop) 773 return self.postparsing_postcmd(stop)
773 def complete_statement(self, line): 774 def complete_statement(self, line):
774 if (not line) or ( 775 if (not line) or (
775 not pyparsing.Or(self.commentGrammars). 776 not pyparsing.Or(self.commentGrammars).
776 setParseAction(lambda x: '').transformString(line)): 777 setParseAction(lambda x: '').transformString(line)):