##// END OF EJS Templates
Merge pull request #8147 from minrk/bigsplit-console...
Thomas Kluyver -
r20885:4ad311ea merge
parent child Browse files
Show More
@@ -0,0 +1,20 b''
1 """
2 Shim to maintain backwards compatibility with old IPython.terminal.console imports.
3 """
4 # Copyright (c) IPython Development Team.
5 # Distributed under the terms of the Modified BSD License.
6
7 from __future__ import print_function
8
9 import sys
10 from warnings import warn
11
12 warn("The `IPython.terminal.console` package has been deprecated. "
13 "You should import from jupyter_console instead.")
14
15 from IPython.utils.shimmodule import ShimModule
16
17 # Unconditionally insert the shim into sys.modules so that further import calls
18 # trigger the custom attribute access above
19
20 sys.modules['IPython.terminal.console'] = ShimModule('console', mirror='jupyter_console')
@@ -1,39 +1,42 b''
1 """A shim module for deprecated imports
1 """A shim module for deprecated imports
2 """
2 """
3 # Copyright (c) IPython Development Team.
3 # Copyright (c) IPython Development Team.
4 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
5
5
6 import sys
6 import types
7 import types
7
8
8 class ShimModule(types.ModuleType):
9 class ShimModule(types.ModuleType):
9
10
10 def __init__(self, *args, **kwargs):
11 def __init__(self, *args, **kwargs):
11 self._mirror = kwargs.pop("mirror")
12 self._mirror = kwargs.pop("mirror")
12 super(ShimModule, self).__init__(*args, **kwargs)
13 super(ShimModule, self).__init__(*args, **kwargs)
14 if sys.version_info >= (3,4):
15 self.__spec__ = __import__(self._mirror).__spec__
13
16
14 def __getattr__(self, key):
17 def __getattr__(self, key):
15 # Use the equivalent of import_item(name), see below
18 # Use the equivalent of import_item(name), see below
16 name = "%s.%s" % (self._mirror, key)
19 name = "%s.%s" % (self._mirror, key)
17
20
18 # NOTE: the code below was copied *verbatim* from
21 # NOTE: the code below was copied *verbatim* from
19 # importstring.import_item. For some very strange reason that makes no
22 # importstring.import_item. For some very strange reason that makes no
20 # sense to me, if we call it *as a function*, it doesn't work. This
23 # sense to me, if we call it *as a function*, it doesn't work. This
21 # has something to do with the deep bowels of the import machinery and
24 # has something to do with the deep bowels of the import machinery and
22 # I couldn't find a way to make the code work as a standard function
25 # I couldn't find a way to make the code work as a standard function
23 # call. But at least since it's an unmodified copy of import_item,
26 # call. But at least since it's an unmodified copy of import_item,
24 # which is used extensively and has a test suite, we can be reasonably
27 # which is used extensively and has a test suite, we can be reasonably
25 # confident this is OK. If anyone finds how to call the function, all
28 # confident this is OK. If anyone finds how to call the function, all
26 # the below could be replaced simply with:
29 # the below could be replaced simply with:
27 #
30 #
28 # from IPython.utils.importstring import import_item
31 # from IPython.utils.importstring import import_item
29 # return import_item('MIRROR.' + key)
32 # return import_item('MIRROR.' + key)
30
33
31 parts = name.rsplit('.', 1)
34 parts = name.rsplit('.', 1)
32 if len(parts) == 2:
35 if len(parts) == 2:
33 # called with 'foo.bar....'
36 # called with 'foo.bar....'
34 package, obj = parts
37 package, obj = parts
35 module = __import__(package, fromlist=[obj])
38 module = __import__(package, fromlist=[obj])
36 return getattr(module, obj)
39 return getattr(module, obj)
37 else:
40 else:
38 # called with un-dotted string
41 # called with un-dotted string
39 return __import__(parts[0])
42 return __import__(parts[0])
1 NO CONTENT: file renamed from IPython/terminal/console/__init__.py to jupyter_console/__init__.py
NO CONTENT: file renamed from IPython/terminal/console/__init__.py to jupyter_console/__init__.py
1 NO CONTENT: file renamed from IPython/terminal/console/__main__.py to jupyter_console/__main__.py
NO CONTENT: file renamed from IPython/terminal/console/__main__.py to jupyter_console/__main__.py
1 NO CONTENT: file renamed from IPython/terminal/console/app.py to jupyter_console/app.py
NO CONTENT: file renamed from IPython/terminal/console/app.py to jupyter_console/app.py
1 NO CONTENT: file renamed from IPython/terminal/console/completer.py to jupyter_console/completer.py
NO CONTENT: file renamed from IPython/terminal/console/completer.py to jupyter_console/completer.py
1 NO CONTENT: file renamed from IPython/terminal/console/interactiveshell.py to jupyter_console/interactiveshell.py
NO CONTENT: file renamed from IPython/terminal/console/interactiveshell.py to jupyter_console/interactiveshell.py
1 NO CONTENT: file renamed from IPython/terminal/console/tests/__init__.py to jupyter_console/tests/__init__.py
NO CONTENT: file renamed from IPython/terminal/console/tests/__init__.py to jupyter_console/tests/__init__.py
1 NO CONTENT: file renamed from IPython/terminal/console/tests/test_console.py to jupyter_console/tests/test_console.py
NO CONTENT: file renamed from IPython/terminal/console/tests/test_console.py to jupyter_console/tests/test_console.py
1 NO CONTENT: file renamed from IPython/terminal/console/tests/test_image_handler.py to jupyter_console/tests/test_image_handler.py
NO CONTENT: file renamed from IPython/terminal/console/tests/test_image_handler.py to jupyter_console/tests/test_image_handler.py
1 NO CONTENT: file renamed from IPython/terminal/console/tests/writetofile.py to jupyter_console/tests/writetofile.py
NO CONTENT: file renamed from IPython/terminal/console/tests/writetofile.py to jupyter_console/tests/writetofile.py
1 NO CONTENT: file renamed from IPython/terminal/console/zmqhistory.py to jupyter_console/zmqhistory.py
NO CONTENT: file renamed from IPython/terminal/console/zmqhistory.py to jupyter_console/zmqhistory.py
General Comments 0
You need to be logged in to leave comments. Login now