summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorcatherine <catherine@Drou>2010-02-16 12:23:47 -0500
committercatherine <catherine@Drou>2010-02-16 12:23:47 -0500
commite3b12ecf2120f799485bd3d5719b6f55666f8ebf (patch)
tree8b3b90234e921b848e9821e8a8b7c3c80bee73cc /cmd2.py
parent72fa800f6cd15a4e86127bd7dc31d27092c63bfe (diff)
downloadcmd2-hg-e3b12ecf2120f799485bd3d5719b6f55666f8ebf.tar.gz
MyInteractiveInterpreter removed
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py32
1 files changed, 3 insertions, 29 deletions
diff --git a/cmd2.py b/cmd2.py
index bdf71f7..336fa8c 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -38,7 +38,7 @@ import glob
import traceback
import platform
import copy
-from code import InteractiveConsole, InteractiveInterpreter, softspace
+from code import InteractiveConsole, InteractiveInterpreter
from optparse import make_option
if sys.version_info[0] > 2:
@@ -350,31 +350,6 @@ def replace_with_file_contents(fname):
class EmbeddedConsoleExit(Exception):
pass
-class MyInteractiveConsole(InteractiveConsole):
- def runcode(self, code):
- """Execute a code object.
-
- When an exception occurs, self.showtraceback() is called to
- display a traceback. All exceptions are caught except
- SystemExit, which is reraised.
-
- A note about KeyboardInterrupt: this exception may occur
- elsewhere in this code, and may not always be caught. The
- caller should be prepared to deal with it.
-
- Copied directly from code.InteractiveInterpreter, except for
- EmbeddedConsoleExit exceptions.
- """
- try:
- exec code in self.locals
- except (SystemExit, EmbeddedConsoleExit):
- raise
- except:
- self.showtraceback()
- else:
- if softspace(sys.stdout, 0):
- print ()
-
def ljust(x, width, fillchar=' '):
'analogous to str.ljust, but works for lists'
if hasattr(x, 'ljust'):
@@ -403,7 +378,7 @@ class Cmd(cmd.Cmd):
feedback_to_output = False # Do include nonessentials in >, | output
quiet = False # Do not suppress nonessential output
debug = False
- locals_in_py = False
+ locals_in_py = True
settable = stubbornDict('''
prompt
colors Colorized output (*nix only)
@@ -1045,9 +1020,8 @@ class Cmd(cmd.Cmd):
interp.runcode(arg)
else:
localvars = (self.locals_in_py and self.pystate) or {}
- interp = MyInteractiveConsole(locals=localvars)
+ interp = InteractiveConsole(locals=localvars)
def quit():
- 'blah'
raise EmbeddedConsoleExit
def onecmd(arg):
return self.onecmd(arg + '\n')