예제 #1
0
"""
Shim to maintain backwards compatibility with old IPython.parallel imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.parallel` package has been deprecated. "
     "You should import from ipython_parallel instead.")

from IPython.utils.shimmodule import ShimModule

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.parallel'] = ShimModule(src='IPython.parallel',
                                             mirror='ipython_parallel')
예제 #2
0
"""
Shim to maintain backwards compatibility with old IPython.nbconvert imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.nbconvert` package has been deprecated since IPython 4.0. "
    "You should import from nbconvert instead.", ShimWarning)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.nbconvert'] = ShimModule(src='IPython.nbconvert',
                                              mirror='nbconvert')
예제 #3
0
"""
Shim to maintain backwards compatibility with old frontend imports.

We have moved all contents of the old `frontend` subpackage into top-level
subpackages (`html`, `qt` and `terminal`), and flattened the notebook into
just `IPython.html`, formerly `IPython.frontend.html.notebook`.

This will let code that was making `from IPython.frontend...` calls continue
working, though a warning will be printed.
"""

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn("The top-level `frontend` package has been deprecated since IPython 1.0. "
     "All its subpackages have been moved to the top `IPython` level.", ShimWarning)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.frontend.html.notebook'] = ShimModule(
    src='IPython.frontend.html.notebook', mirror='IPython.html')
sys.modules['IPython.frontend'] = ShimModule(
    src='IPython.frontend', mirror='IPython')
예제 #4
0
파일: html.py 프로젝트: xguse/ipython
"""
Shim to maintain backwards compatibility with old IPython.html imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.html` package has been deprecated. "
     "You should import from `notebook` instead. "
     "`IPython.html.widgets` has moved to `ipywidgets`.")

from IPython.utils.shimmodule import ShimModule

_widgets = sys.modules['IPython.html.widgets'] = ShimModule(
    src='IPython.html.widgets', mirror='ipywidgets')

_html = ShimModule(src='IPython.html', mirror='notebook')

# hook up widgets
_html.widgets = _widgets
sys.modules['IPython.html'] = _html

if __name__ == '__main__':
    from notebook import notebookapp as app
    app.launch_new_instance()
예제 #5
0
def test_shimmodule_repr_forwards_to_module():
    shim_module = ShimModule("shim_module", mirror="IPython")
    assert repr(shim_module) == repr(IPython)
예제 #6
0
Shim to maintain backwards compatibility with old IPython.kernel imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.kernel` package has been deprecated since IPython 4.0."
    "You should import from ipykernel or jupyter_client instead.", ShimWarning)

# zmq subdir is gone
sys.modules['IPython.kernel.zmq.session'] = ShimModule(
    src='IPython.kernel.zmq.session', mirror='jupyter_client.session')
sys.modules['IPython.kernel.zmq'] = ShimModule(src='IPython.kernel.zmq',
                                               mirror='ipykernel')

for pkg in ('comm', 'inprocess'):
    src = 'IPython.kernel.%s' % pkg
    sys.modules[src] = ShimModule(src=src, mirror='ipykernel.%s' % pkg)

for pkg in ('ioloop', 'blocking'):
    src = 'IPython.kernel.%s' % pkg
    sys.modules[src] = ShimModule(src=src, mirror='jupyter_client.%s' % pkg)

# required for `from IPython.kernel import PKG`
from ipykernel import comm, inprocess
from jupyter_client import ioloop, blocking
# static API
예제 #7
0
파일: html.py 프로젝트: 0038lana/Test-Task
"""
Shim to maintain backwards compatibility with old IPython.html imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn("The `IPython.html` package has been deprecated. "
     "You should import from `notebook` instead. "
     "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

_widgets = sys.modules['IPython.html.widgets'] = ShimModule(
    src='IPython.html.widgets', mirror='ipywidgets')

_html = ShimModule(
    src='IPython.html', mirror='notebook')

# hook up widgets
_html.widgets = _widgets
sys.modules['IPython.html'] = _html

if __name__ == '__main__':
    from notebook import notebookapp as app
    app.launch_new_instance()
예제 #8
0
파일: qt.py 프로젝트: terrdavis/ipython
"""
Shim to maintain backwards compatibility with old IPython.qt imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.qt` package has been deprecated since IPython 4.0. "
    "You should import from qtconsole instead.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

_console = sys.modules["IPython.qt.console"] = ShimModule(
    src="IPython.qt.console", mirror="qtconsole"
)

_qt = ShimModule(src="IPython.qt", mirror="qtconsole")

_qt.console = _console
sys.modules["IPython.qt"] = _qt
예제 #9
0
We have moved all contents of the old `frontend` subpackage into top-level
subpackages (`html`, `qt` and `terminal`), and flattened the notebook into
just `IPython.html`, formerly `IPython.frontend.html.notebook`.

This will let code that was making `from IPython.frontend...` calls continue
working, though a warning will be printed.
"""

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The top-level `frontend` package has been deprecated since IPython 1.0. "
    "All its subpackages have been moved to the top `IPython` level.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules["IPython.frontend.html.notebook"] = ShimModule(
    src="IPython.frontend.html.notebook", mirror="IPython.html")
sys.modules["IPython.frontend"] = ShimModule(src="IPython.frontend",
                                             mirror="IPython")
예제 #10
0
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.html` package has been deprecated since IPython 4.0. "
    "You should import from `notebook` instead. "
    "`IPython.html.widgets` has moved to `ipywidgets`.",
    ShimWarning,
)

_widgets = sys.modules["IPython.html.widgets"] = ShimModule(
    src="IPython.html.widgets", mirror="ipywidgets"
)

_html = ShimModule(src="IPython.html", mirror="notebook")

# hook up widgets
_html.widgets = _widgets
sys.modules["IPython.html"] = _html

if __name__ == "__main__":
    from notebook import notebookapp as app

    app.launch_new_instance()
예제 #11
0
"""
Shim to maintain backwards compatibility with old IPython.parallel imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.parallel` package has been deprecated since IPython 4.0. "
    "You should import from ipyparallel instead.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules["IPython.parallel"] = ShimModule(
    src="IPython.parallel", mirror="ipyparallel"
)
예제 #12
0
"""
Shim to maintain backwards compatibility with old IPython.html imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.html` package has been deprecated. "
     "You should import from `jupyter_notebook` instead. "
     "`IPython.html.widgets` has moved to `ipython_widgets`.")

from IPython.utils.shimmodule import ShimModule

sys.modules['IPython.html.widgets'] = ShimModule(src='IPython.html.widgets',
                                                 mirror='ipython_widgets')

sys.modules['IPython.html'] = ShimModule(src='IPython.html',
                                         mirror='jupyter_notebook')

if __name__ == '__main__':
    from jupyter_notebook import notebookapp as app
    app.launch_new_instance()
예제 #13
0
파일: console.py 프로젝트: xguse/ipython
"""
Shim to maintain backwards compatibility with old IPython.terminal.console imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from __future__ import print_function

import sys
from warnings import warn

warn("The `IPython.terminal.console` package has been deprecated. "
     "You should import from jupyter_console instead.")

from IPython.utils.shimmodule import ShimModule

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.terminal.console'] = ShimModule(
    src='IPython.terminal.console', mirror='jupyter_console')
예제 #14
0
"""
Shim to maintain backwards compatibility with old IPython.terminal.console imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.terminal.console` package has been deprecated since IPython 4.0. "
    "You should import from jupyter_console instead.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules["IPython.terminal.console"] = ShimModule(
    src="IPython.terminal.console", mirror="jupyter_console")
예제 #15
0
파일: qt.py 프로젝트: BarnetteME1/DnD-stuff
"""
Shim to maintain backwards compatibility with old IPython.qt imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn("The `IPython.qt` package has been deprecated since IPython 4.0. "
     "You should import from qtconsole instead.", ShimWarning)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

_console = sys.modules['IPython.qt.console'] = ShimModule(
    src='IPython.qt.console', mirror='qtconsole')

_qt = ShimModule(src='IPython.qt', mirror='qtconsole')

_qt.console = _console
sys.modules['IPython.qt'] = _qt
예제 #16
0
"""
Shim to maintain backwards compatibility with old IPython.config imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.config` package has been deprecated. "
     "You should import from traitlets.config instead.")

from IPython.utils.shimmodule import ShimModule

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.config'] = ShimModule(src='IPython.config',
                                           mirror='traitlets.config')
예제 #17
0
"""
Shim to maintain backwards compatibility with old IPython.nbformat imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.nbformat` package has been deprecated. "
     "You should import from jupyter_nbformat instead.")

from IPython.utils.shimmodule import ShimModule

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.nbformat'] = ShimModule(
    src='IPython.nbformat', mirror='jupyter_nbformat')
예제 #18
0
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.kernel` package has been deprecated since IPython 4.0."
    "You should import from ipykernel or jupyter_client instead.",
    ShimWarning,
)

# zmq subdir is gone
sys.modules["IPython.kernel.zmq.session"] = ShimModule(
    src="IPython.kernel.zmq.session", mirror="jupyter_client.session")
sys.modules["IPython.kernel.zmq"] = ShimModule(src="IPython.kernel.zmq",
                                               mirror="ipykernel")

for pkg in ("comm", "inprocess"):
    src = "IPython.kernel.%s" % pkg
    sys.modules[src] = ShimModule(src=src, mirror="ipykernel.%s" % pkg)

for pkg in ("ioloop", "blocking"):
    src = "IPython.kernel.%s" % pkg
    sys.modules[src] = ShimModule(src=src, mirror="jupyter_client.%s" % pkg)

# required for `from IPython.kernel import PKG`
from ipykernel import comm, inprocess
from jupyter_client import ioloop, blocking
예제 #19
0
"""
Shim to maintain backwards compatibility with old IPython.nbconvert imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.nbconvert` package has been deprecated since IPython 4.0. "
    "You should import from nbconvert instead.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules["IPython.nbconvert"] = ShimModule(
    src="IPython.nbconvert", mirror="nbconvert"
)
예제 #20
0
"""
Shim to maintain backwards compatibility with old IPython.qt imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.qt` package has been deprecated since IPython 4.0. "
    "You should import from qtconsole instead.", ShimWarning)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

_console = sys.modules['IPython.qt.console'] = ShimModule(
    src='IPython.qt.console', mirror='qtconsole')

_qt = ShimModule(src='IPython.qt', mirror='qtconsole')

_qt.console = _console
sys.modules['IPython.qt'] = _qt
예제 #21
0
"""
Shim to maintain backwards compatibility with old IPython.config imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

from IPython.utils.shimmodule import ShimModule, ShimWarning

warn(
    "The `IPython.config` package has been deprecated since IPython 4.0. "
    "You should import from traitlets.config instead.",
    ShimWarning,
)

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules["IPython.config"] = ShimModule(src="IPython.config",
                                           mirror="traitlets.config")
예제 #22
0
"""
Shim to maintain backwards compatibility with old IPython.qt imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.qt` package has been deprecated. "
     "You should import from jupyter_qtconsole instead.")

from IPython.utils.shimmodule import ShimModule

# Unconditionally insert the shim into sys.modules so that further import calls
# trigger the custom attribute access above

sys.modules['IPython.qt'] = ShimModule(src='IPython.qt',
                                       mirror='jupyter_qtconsole')
예제 #23
0
"""
Shim to maintain backwards compatibility with old IPython.html imports.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import sys
from warnings import warn

warn("The `IPython.html` package has been deprecated. "
     "You should import from jupyter_notebook instead.")

from IPython.utils.shimmodule import ShimModule

sys.modules['IPython.html'] = ShimModule(src='IPython.html',
                                         mirror='jupyter_notebook')

if __name__ == '__main__':
    from jupyter_notebook import notebookapp as app
    app.launch_new_instance()
예제 #24
0
def test_shimmodule_repr_does_not_fail_on_import_error():
    shim_module = ShimModule("shim_module", mirror="mirrored_module_does_not_exist")
    repr(shim_module)