Mercurial > python-cmd2
changeset 275:f62e9fbb3f90
restoring python 2.4 compatibility
author | catherine@cordelia |
---|---|
date | Thu, 28 May 2009 17:33:19 -0400 |
parents | 540315f06a17 |
children | 9bcfa4f81825 |
files | cmd2.py setup.py |
diffstat | 2 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd2.py Mon May 04 11:42:06 2009 -0400 +++ b/cmd2.py Thu May 28 17:33:19 2009 -0400 @@ -26,7 +26,7 @@ import unittest, string, datetime, urllib, glob from code import InteractiveConsole, InteractiveInterpreter, softspace from optparse import make_option -__version__ = '0.5.3' +__version__ = '0.5.4' class OptionParser(optparse.OptionParser): def exit(self, status=0, msg=None): @@ -649,21 +649,22 @@ if statement.parsed.output == '>>': self.stdout.write(getPasteBuffer()) try: - # "heart" of the command, replace's cmd's onecmd() - self.lastcmd = statement.parsed.expanded - funcname = self.func_named(statement.parsed.command) - if not funcname: - return self.postparsing_postcmd(self.default(statement)) try: - func = getattr(self, funcname) - except AttributeError: - return self.postparsing_postcmd(self.default(statement)) - timestart = datetime.datetime.now() - stop = func(statement) - if self.timing: - self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart)) - except Exception, e: - self.perror(e) + # "heart" of the command, replace's cmd's onecmd() + self.lastcmd = statement.parsed.expanded + funcname = self.func_named(statement.parsed.command) + if not funcname: + return self.postparsing_postcmd(self.default(statement)) + try: + func = getattr(self, funcname) + except AttributeError: + return self.postparsing_postcmd(self.default(statement)) + timestart = datetime.datetime.now() + stop = func(statement) + if self.timing: + self.pfeedback('Elapsed: %s' % str(datetime.datetime.now() - timestart)) + except Exception, e: + self.perror(e) finally: if statekeeper: if statement.parsed.output and not statement.parsed.outputTo: