##// END OF EJS Templates
Merge branch 'cleanup-old-code' of http://github.com/takowl/ipython into takowl-cleanup-old-code...
Fernando Perez -
r3180:59ccc837 merge
parent child Browse files
Show More
@@ -22,13 +22,11 b' import __future__'
22 import abc
22 import abc
23 import atexit
23 import atexit
24 import codeop
24 import codeop
25 import exceptions
26 import new
27 import os
25 import os
28 import re
26 import re
29 import string
30 import sys
27 import sys
31 import tempfile
28 import tempfile
29 import types
32 from contextlib import nested
30 from contextlib import nested
33
31
34 from IPython.config.configurable import Configurable
32 from IPython.config.configurable import Configurable
@@ -104,7 +102,7 b' def softspace(file, newvalue):'
104
102
105 def no_op(*a, **kw): pass
103 def no_op(*a, **kw): pass
106
104
107 class SpaceInInput(exceptions.Exception): pass
105 class SpaceInInput(Exception): pass
108
106
109 class Bunch: pass
107 class Bunch: pass
110
108
@@ -521,7 +519,7 b' class InteractiveShell(Configurable, Magic):'
521 def restore_sys_module_state(self):
519 def restore_sys_module_state(self):
522 """Restore the state of the sys module."""
520 """Restore the state of the sys module."""
523 try:
521 try:
524 for k, v in self._orig_sys_module_state.items():
522 for k, v in self._orig_sys_module_state.iteritems():
525 setattr(sys, k, v)
523 setattr(sys, k, v)
526 except AttributeError:
524 except AttributeError:
527 pass
525 pass
@@ -559,7 +557,7 b' class InteractiveShell(Configurable, Magic):'
559 # accepts it. Probably at least check that the hook takes the number
557 # accepts it. Probably at least check that the hook takes the number
560 # of args it's supposed to.
558 # of args it's supposed to.
561
559
562 f = new.instancemethod(hook,self,self.__class__)
560 f = types.MethodType(hook,self)
563
561
564 # check if the hook is for strdispatcher first
562 # check if the hook is for strdispatcher first
565 if str_key is not None:
563 if str_key is not None:
@@ -1313,7 +1311,7 b' class InteractiveShell(Configurable, Magic):'
1313 # The return value must be
1311 # The return value must be
1314 return structured_traceback
1312 return structured_traceback
1315
1313
1316 This will be made into an instance method (via new.instancemethod)
1314 This will be made into an instance method (via types.MethodType)
1317 of IPython itself, and it will be called if any of the exceptions
1315 of IPython itself, and it will be called if any of the exceptions
1318 listed in the exc_tuple are caught. If the handler is None, an
1316 listed in the exc_tuple are caught. If the handler is None, an
1319 internal basic one is used, which just prints basic info.
1317 internal basic one is used, which just prints basic info.
@@ -1334,7 +1332,7 b' class InteractiveShell(Configurable, Magic):'
1334
1332
1335 if handler is None: handler = dummy_handler
1333 if handler is None: handler = dummy_handler
1336
1334
1337 self.CustomTB = new.instancemethod(handler,self,self.__class__)
1335 self.CustomTB = types.MethodType(handler,self)
1338 self.custom_exceptions = exc_tuple
1336 self.custom_exceptions = exc_tuple
1339
1337
1340 def excepthook(self, etype, value, tb):
1338 def excepthook(self, etype, value, tb):
@@ -1538,8 +1536,7 b' class InteractiveShell(Configurable, Magic):'
1538 # Remove some chars from the delimiters list. If we encounter
1536 # Remove some chars from the delimiters list. If we encounter
1539 # unicode chars, discard them.
1537 # unicode chars, discard them.
1540 delims = readline.get_completer_delims().encode("ascii", "ignore")
1538 delims = readline.get_completer_delims().encode("ascii", "ignore")
1541 delims = delims.translate(string._idmap,
1539 delims = delims.translate(None, self.readline_remove_delims)
1542 self.readline_remove_delims)
1543 delims = delims.replace(ESC_MAGIC, '')
1540 delims = delims.replace(ESC_MAGIC, '')
1544 readline.set_completer_delims(delims)
1541 readline.set_completer_delims(delims)
1545 # otherwise we end up with a monster history after a while:
1542 # otherwise we end up with a monster history after a while:
@@ -1676,8 +1673,7 b' class InteractiveShell(Configurable, Magic):'
1676 The position argument (defaults to 0) is the index in the completers
1673 The position argument (defaults to 0) is the index in the completers
1677 list where you want the completer to be inserted."""
1674 list where you want the completer to be inserted."""
1678
1675
1679 newcomp = new.instancemethod(completer,self.Completer,
1676 newcomp = types.MethodType(completer,self.Completer)
1680 self.Completer.__class__)
1681 self.Completer.matchers.insert(pos,newcomp)
1677 self.Completer.matchers.insert(pos,newcomp)
1682
1678
1683 def set_readline_completer(self):
1679 def set_readline_completer(self):
@@ -1753,7 +1749,7 b' class InteractiveShell(Configurable, Magic):'
1753 """
1749 """
1754
1750
1755 import new
1751 import new
1756 im = new.instancemethod(func,self, self.__class__)
1752 im = types.MethodType(func,self)
1757 old = getattr(self, "magic_" + magicname, None)
1753 old = getattr(self, "magic_" + magicname, None)
1758 setattr(self, "magic_" + magicname, im)
1754 setattr(self, "magic_" + magicname, im)
1759 return old
1755 return old
@@ -2112,8 +2108,7 b' class InteractiveShell(Configurable, Magic):'
2112 list.append(self, val)
2108 list.append(self, val)
2113
2109
2114 import new
2110 import new
2115 self.input_hist.append = new.instancemethod(myapp, self.input_hist,
2111 self.input_hist.append = types.MethodType(myapp, self.input_hist)
2116 list)
2117 # End dbg
2112 # End dbg
2118
2113
2119 # All user code execution must happen with our context managers active
2114 # All user code execution must happen with our context managers active
@@ -22,7 +22,6 b' import StringIO'
22 import inspect
22 import inspect
23 import linecache
23 import linecache
24 import os
24 import os
25 import string
26 import sys
25 import sys
27 import types
26 import types
28 from collections import namedtuple
27 from collections import namedtuple
@@ -450,7 +449,7 b' class Inspector:'
450 if not detail_level and len(ostr)>string_max:
449 if not detail_level and len(ostr)>string_max:
451 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
450 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
452 ostr = ("\n" + " " * len(str_head.expandtabs())).\
451 ostr = ("\n" + " " * len(str_head.expandtabs())).\
453 join(map(string.strip,ostr.split("\n")))
452 join(q.strip() for q in ostr.split("\n"))
454 if ostr.find('\n') > -1:
453 if ostr.find('\n') > -1:
455 # Print multi-line strings starting at the next line.
454 # Print multi-line strings starting at the next line.
456 str_sep = '\n'
455 str_sep = '\n'
@@ -675,7 +674,7 b' class Inspector:'
675 if not detail_level and len(ostr)>string_max:
674 if not detail_level and len(ostr)>string_max:
676 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
675 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
677 ostr = ("\n" + " " * len(str_head.expandtabs())).\
676 ostr = ("\n" + " " * len(str_head.expandtabs())).\
678 join(map(string.strip,ostr.split("\n")))
677 join(q.strip() for q in ostr.split("\n"))
679 if ostr.find('\n') > -1:
678 if ostr.find('\n') > -1:
680 # Print multi-line strings starting at the next line.
679 # Print multi-line strings starting at the next line.
681 str_sep = '\n'
680 str_sep = '\n'
@@ -77,7 +77,6 b' import linecache'
77 import os
77 import os
78 import pydoc
78 import pydoc
79 import re
79 import re
80 import string
81 import sys
80 import sys
82 import time
81 import time
83 import tokenize
82 import tokenize
@@ -719,7 +718,7 b' class VerboseTB(TBTools):'
719
718
720 if self.long_header:
719 if self.long_header:
721 # Header with the exception type, python version, and date
720 # Header with the exception type, python version, and date
722 pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable
721 pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
723 date = time.ctime(time.time())
722 date = time.ctime(time.time())
724
723
725 head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal,
724 head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal,
@@ -75,7 +75,6 b' each time the instance is evaluated with str(instance). For example:'
75 __author__ = 'Ka-Ping Yee <ping@lfw.org>'
75 __author__ = 'Ka-Ping Yee <ping@lfw.org>'
76 __license__ = 'MIT'
76 __license__ = 'MIT'
77
77
78 import string
79 import sys
78 import sys
80 from tokenize import tokenprog
79 from tokenize import tokenprog
81
80
@@ -66,7 +66,6 b' $Id: pexpect.py 507 2007-12-27 02:40:52Z noah $'
66 try:
66 try:
67 import os, sys, time
67 import os, sys, time
68 import select
68 import select
69 import string
70 import re
69 import re
71 import struct
70 import struct
72 import resource
71 import resource
@@ -1778,8 +1777,7 b' def which (filename):'
1778
1777
1779 # Oddly enough this was the one line that made Pexpect
1778 # Oddly enough this was the one line that made Pexpect
1780 # incompatible with Python 1.5.2.
1779 # incompatible with Python 1.5.2.
1781 #pathlist = p.split (os.pathsep)
1780 pathlist = p.split(os.pathsep)
1782 pathlist = string.split (p, os.pathsep)
1783
1781
1784 for path in pathlist:
1782 for path in pathlist:
1785 f = os.path.join(path, filename)
1783 f = os.path.join(path, filename)
General Comments 0
You need to be logged in to leave comments. Login now