diff --git a/IPython/nbformat.py b/IPython/nbformat.py new file mode 100644 index 0000000..e5d44e1 --- /dev/null +++ b/IPython/nbformat.py @@ -0,0 +1,22 @@ +""" +Shim to maintain backwards compatibility with old IPython.nbformat imports. +""" +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + +from __future__ import print_function + +# Stdlib +import sys +import types +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('nbformat', mirror='jupyter_nbformat') diff --git a/IPython/nbformat/__init__.py b/jupyter_nbformat/__init__.py similarity index 100% rename from IPython/nbformat/__init__.py rename to jupyter_nbformat/__init__.py diff --git a/IPython/nbformat/converter.py b/jupyter_nbformat/converter.py similarity index 100% rename from IPython/nbformat/converter.py rename to jupyter_nbformat/converter.py diff --git a/IPython/nbformat/current.py b/jupyter_nbformat/current.py similarity index 100% rename from IPython/nbformat/current.py rename to jupyter_nbformat/current.py diff --git a/IPython/nbformat/notebooknode.py b/jupyter_nbformat/notebooknode.py similarity index 100% rename from IPython/nbformat/notebooknode.py rename to jupyter_nbformat/notebooknode.py diff --git a/IPython/nbformat/reader.py b/jupyter_nbformat/reader.py similarity index 100% rename from IPython/nbformat/reader.py rename to jupyter_nbformat/reader.py diff --git a/IPython/nbformat/sign.py b/jupyter_nbformat/sign.py similarity index 100% rename from IPython/nbformat/sign.py rename to jupyter_nbformat/sign.py diff --git a/IPython/nbformat/tests/__init__.py b/jupyter_nbformat/tests/__init__.py similarity index 100% rename from IPython/nbformat/tests/__init__.py rename to jupyter_nbformat/tests/__init__.py diff --git a/IPython/nbformat/tests/base.py b/jupyter_nbformat/tests/base.py similarity index 84% rename from IPython/nbformat/tests/base.py rename to jupyter_nbformat/tests/base.py index 349006f..32a116c 100644 --- a/IPython/nbformat/tests/base.py +++ b/jupyter_nbformat/tests/base.py @@ -30,13 +30,4 @@ class TestsBase(unittest.TestCase): def _get_files_path(self): - - #Get the relative path to this module in the IPython directory. - names = self.__module__.split(u'.')[1:-1] - - #Build a path using the IPython directory and the relative path we just - #found. - path = IPython.__path__[0] - for name in names: - path = os.path.join(path, name) - return path + return os.path.dirname(__file__) diff --git a/IPython/nbformat/tests/invalid.ipynb b/jupyter_nbformat/tests/invalid.ipynb similarity index 100% rename from IPython/nbformat/tests/invalid.ipynb rename to jupyter_nbformat/tests/invalid.ipynb diff --git a/IPython/nbformat/tests/test2.ipynb b/jupyter_nbformat/tests/test2.ipynb similarity index 100% rename from IPython/nbformat/tests/test2.ipynb rename to jupyter_nbformat/tests/test2.ipynb diff --git a/IPython/nbformat/tests/test3.ipynb b/jupyter_nbformat/tests/test3.ipynb similarity index 100% rename from IPython/nbformat/tests/test3.ipynb rename to jupyter_nbformat/tests/test3.ipynb diff --git a/IPython/nbformat/tests/test4.ipynb b/jupyter_nbformat/tests/test4.ipynb similarity index 100% rename from IPython/nbformat/tests/test4.ipynb rename to jupyter_nbformat/tests/test4.ipynb diff --git a/IPython/nbformat/tests/test4plus.ipynb b/jupyter_nbformat/tests/test4plus.ipynb similarity index 100% rename from IPython/nbformat/tests/test4plus.ipynb rename to jupyter_nbformat/tests/test4plus.ipynb diff --git a/IPython/nbformat/tests/test_api.py b/jupyter_nbformat/tests/test_api.py similarity index 100% rename from IPython/nbformat/tests/test_api.py rename to jupyter_nbformat/tests/test_api.py diff --git a/IPython/nbformat/tests/test_convert.py b/jupyter_nbformat/tests/test_convert.py similarity index 100% rename from IPython/nbformat/tests/test_convert.py rename to jupyter_nbformat/tests/test_convert.py diff --git a/IPython/nbformat/tests/test_reader.py b/jupyter_nbformat/tests/test_reader.py similarity index 100% rename from IPython/nbformat/tests/test_reader.py rename to jupyter_nbformat/tests/test_reader.py diff --git a/IPython/nbformat/tests/test_sign.py b/jupyter_nbformat/tests/test_sign.py similarity index 100% rename from IPython/nbformat/tests/test_sign.py rename to jupyter_nbformat/tests/test_sign.py diff --git a/IPython/nbformat/tests/test_validator.py b/jupyter_nbformat/tests/test_validator.py similarity index 100% rename from IPython/nbformat/tests/test_validator.py rename to jupyter_nbformat/tests/test_validator.py diff --git a/IPython/nbformat/v1/__init__.py b/jupyter_nbformat/v1/__init__.py similarity index 100% rename from IPython/nbformat/v1/__init__.py rename to jupyter_nbformat/v1/__init__.py diff --git a/IPython/nbformat/v1/convert.py b/jupyter_nbformat/v1/convert.py similarity index 100% rename from IPython/nbformat/v1/convert.py rename to jupyter_nbformat/v1/convert.py diff --git a/IPython/nbformat/v1/nbbase.py b/jupyter_nbformat/v1/nbbase.py similarity index 100% rename from IPython/nbformat/v1/nbbase.py rename to jupyter_nbformat/v1/nbbase.py diff --git a/IPython/nbformat/v1/nbjson.py b/jupyter_nbformat/v1/nbjson.py similarity index 100% rename from IPython/nbformat/v1/nbjson.py rename to jupyter_nbformat/v1/nbjson.py diff --git a/IPython/nbformat/v1/rwbase.py b/jupyter_nbformat/v1/rwbase.py similarity index 100% rename from IPython/nbformat/v1/rwbase.py rename to jupyter_nbformat/v1/rwbase.py diff --git a/IPython/nbformat/v1/tests/__init__.py b/jupyter_nbformat/v1/tests/__init__.py similarity index 100% rename from IPython/nbformat/v1/tests/__init__.py rename to jupyter_nbformat/v1/tests/__init__.py diff --git a/IPython/nbformat/v1/tests/nbexamples.py b/jupyter_nbformat/v1/tests/nbexamples.py similarity index 100% rename from IPython/nbformat/v1/tests/nbexamples.py rename to jupyter_nbformat/v1/tests/nbexamples.py diff --git a/IPython/nbformat/v1/tests/test_json.py b/jupyter_nbformat/v1/tests/test_json.py similarity index 100% rename from IPython/nbformat/v1/tests/test_json.py rename to jupyter_nbformat/v1/tests/test_json.py diff --git a/IPython/nbformat/v1/tests/test_nbbase.py b/jupyter_nbformat/v1/tests/test_nbbase.py similarity index 100% rename from IPython/nbformat/v1/tests/test_nbbase.py rename to jupyter_nbformat/v1/tests/test_nbbase.py diff --git a/IPython/nbformat/v2/__init__.py b/jupyter_nbformat/v2/__init__.py similarity index 100% rename from IPython/nbformat/v2/__init__.py rename to jupyter_nbformat/v2/__init__.py diff --git a/IPython/nbformat/v2/convert.py b/jupyter_nbformat/v2/convert.py similarity index 100% rename from IPython/nbformat/v2/convert.py rename to jupyter_nbformat/v2/convert.py diff --git a/IPython/nbformat/v2/nbbase.py b/jupyter_nbformat/v2/nbbase.py similarity index 100% rename from IPython/nbformat/v2/nbbase.py rename to jupyter_nbformat/v2/nbbase.py diff --git a/IPython/nbformat/v2/nbjson.py b/jupyter_nbformat/v2/nbjson.py similarity index 100% rename from IPython/nbformat/v2/nbjson.py rename to jupyter_nbformat/v2/nbjson.py diff --git a/IPython/nbformat/v2/nbpy.py b/jupyter_nbformat/v2/nbpy.py similarity index 100% rename from IPython/nbformat/v2/nbpy.py rename to jupyter_nbformat/v2/nbpy.py diff --git a/IPython/nbformat/v2/nbxml.py b/jupyter_nbformat/v2/nbxml.py similarity index 100% rename from IPython/nbformat/v2/nbxml.py rename to jupyter_nbformat/v2/nbxml.py diff --git a/IPython/nbformat/v2/rwbase.py b/jupyter_nbformat/v2/rwbase.py similarity index 100% rename from IPython/nbformat/v2/rwbase.py rename to jupyter_nbformat/v2/rwbase.py diff --git a/IPython/nbformat/v2/tests/__init__.py b/jupyter_nbformat/v2/tests/__init__.py similarity index 100% rename from IPython/nbformat/v2/tests/__init__.py rename to jupyter_nbformat/v2/tests/__init__.py diff --git a/IPython/nbformat/v2/tests/nbexamples.py b/jupyter_nbformat/v2/tests/nbexamples.py similarity index 100% rename from IPython/nbformat/v2/tests/nbexamples.py rename to jupyter_nbformat/v2/tests/nbexamples.py diff --git a/IPython/nbformat/v2/tests/test_json.py b/jupyter_nbformat/v2/tests/test_json.py similarity index 100% rename from IPython/nbformat/v2/tests/test_json.py rename to jupyter_nbformat/v2/tests/test_json.py diff --git a/IPython/nbformat/v2/tests/test_nbbase.py b/jupyter_nbformat/v2/tests/test_nbbase.py similarity index 100% rename from IPython/nbformat/v2/tests/test_nbbase.py rename to jupyter_nbformat/v2/tests/test_nbbase.py diff --git a/IPython/nbformat/v2/tests/test_nbpy.py b/jupyter_nbformat/v2/tests/test_nbpy.py similarity index 100% rename from IPython/nbformat/v2/tests/test_nbpy.py rename to jupyter_nbformat/v2/tests/test_nbpy.py diff --git a/IPython/nbformat/v3/__init__.py b/jupyter_nbformat/v3/__init__.py similarity index 100% rename from IPython/nbformat/v3/__init__.py rename to jupyter_nbformat/v3/__init__.py diff --git a/IPython/nbformat/v3/convert.py b/jupyter_nbformat/v3/convert.py similarity index 98% rename from IPython/nbformat/v3/convert.py rename to jupyter_nbformat/v3/convert.py index c2857bb..04b44b7 100644 --- a/IPython/nbformat/v3/convert.py +++ b/jupyter_nbformat/v3/convert.py @@ -8,7 +8,7 @@ from .nbbase import ( nbformat, nbformat_minor ) -from IPython.nbformat import v2 +from jupyter_nbformat import v2 def _unbytes(obj): """There should be no bytes objects in a notebook diff --git a/IPython/nbformat/v3/nbbase.py b/jupyter_nbformat/v3/nbbase.py similarity index 100% rename from IPython/nbformat/v3/nbbase.py rename to jupyter_nbformat/v3/nbbase.py diff --git a/IPython/nbformat/v3/nbformat.v3.schema.json b/jupyter_nbformat/v3/nbformat.v3.schema.json similarity index 100% rename from IPython/nbformat/v3/nbformat.v3.schema.json rename to jupyter_nbformat/v3/nbformat.v3.schema.json diff --git a/IPython/nbformat/v3/nbjson.py b/jupyter_nbformat/v3/nbjson.py similarity index 100% rename from IPython/nbformat/v3/nbjson.py rename to jupyter_nbformat/v3/nbjson.py diff --git a/IPython/nbformat/v3/nbpy.py b/jupyter_nbformat/v3/nbpy.py similarity index 100% rename from IPython/nbformat/v3/nbpy.py rename to jupyter_nbformat/v3/nbpy.py diff --git a/IPython/nbformat/v3/rwbase.py b/jupyter_nbformat/v3/rwbase.py similarity index 100% rename from IPython/nbformat/v3/rwbase.py rename to jupyter_nbformat/v3/rwbase.py diff --git a/IPython/nbformat/v3/tests/__init__.py b/jupyter_nbformat/v3/tests/__init__.py similarity index 100% rename from IPython/nbformat/v3/tests/__init__.py rename to jupyter_nbformat/v3/tests/__init__.py diff --git a/IPython/nbformat/v3/tests/formattest.py b/jupyter_nbformat/v3/tests/formattest.py similarity index 100% rename from IPython/nbformat/v3/tests/formattest.py rename to jupyter_nbformat/v3/tests/formattest.py diff --git a/IPython/nbformat/v3/tests/nbexamples.py b/jupyter_nbformat/v3/tests/nbexamples.py similarity index 100% rename from IPython/nbformat/v3/tests/nbexamples.py rename to jupyter_nbformat/v3/tests/nbexamples.py diff --git a/IPython/nbformat/v3/tests/test_json.py b/jupyter_nbformat/v3/tests/test_json.py similarity index 100% rename from IPython/nbformat/v3/tests/test_json.py rename to jupyter_nbformat/v3/tests/test_json.py diff --git a/IPython/nbformat/v3/tests/test_misc.py b/jupyter_nbformat/v3/tests/test_misc.py similarity index 100% rename from IPython/nbformat/v3/tests/test_misc.py rename to jupyter_nbformat/v3/tests/test_misc.py diff --git a/IPython/nbformat/v3/tests/test_nbbase.py b/jupyter_nbformat/v3/tests/test_nbbase.py similarity index 100% rename from IPython/nbformat/v3/tests/test_nbbase.py rename to jupyter_nbformat/v3/tests/test_nbbase.py diff --git a/IPython/nbformat/v3/tests/test_nbpy.py b/jupyter_nbformat/v3/tests/test_nbpy.py similarity index 100% rename from IPython/nbformat/v3/tests/test_nbpy.py rename to jupyter_nbformat/v3/tests/test_nbpy.py diff --git a/IPython/nbformat/v4/__init__.py b/jupyter_nbformat/v4/__init__.py similarity index 100% rename from IPython/nbformat/v4/__init__.py rename to jupyter_nbformat/v4/__init__.py diff --git a/IPython/nbformat/v4/convert.py b/jupyter_nbformat/v4/convert.py similarity index 96% rename from IPython/nbformat/v4/convert.py rename to jupyter_nbformat/v4/convert.py index a6c3f36..b25efd9 100644 --- a/IPython/nbformat/v4/convert.py +++ b/jupyter_nbformat/v4/convert.py @@ -11,7 +11,7 @@ from .nbbase import ( NotebookNode, ) -from IPython.nbformat import v3 +from jupyter_nbformat import v3 from IPython.utils.log import get_logger def _warn_if_invalid(nb, version): diff --git a/IPython/nbformat/v4/nbbase.py b/jupyter_nbformat/v4/nbbase.py similarity index 100% rename from IPython/nbformat/v4/nbbase.py rename to jupyter_nbformat/v4/nbbase.py diff --git a/IPython/nbformat/v4/nbformat.v4.schema.json b/jupyter_nbformat/v4/nbformat.v4.schema.json similarity index 100% rename from IPython/nbformat/v4/nbformat.v4.schema.json rename to jupyter_nbformat/v4/nbformat.v4.schema.json diff --git a/IPython/nbformat/v4/nbjson.py b/jupyter_nbformat/v4/nbjson.py similarity index 100% rename from IPython/nbformat/v4/nbjson.py rename to jupyter_nbformat/v4/nbjson.py diff --git a/IPython/nbformat/v4/rwbase.py b/jupyter_nbformat/v4/rwbase.py similarity index 100% rename from IPython/nbformat/v4/rwbase.py rename to jupyter_nbformat/v4/rwbase.py diff --git a/IPython/nbformat/v4/tests/__init__.py b/jupyter_nbformat/v4/tests/__init__.py similarity index 100% rename from IPython/nbformat/v4/tests/__init__.py rename to jupyter_nbformat/v4/tests/__init__.py diff --git a/IPython/nbformat/v4/tests/formattest.py b/jupyter_nbformat/v4/tests/formattest.py similarity index 100% rename from IPython/nbformat/v4/tests/formattest.py rename to jupyter_nbformat/v4/tests/formattest.py diff --git a/IPython/nbformat/v4/tests/nbexamples.py b/jupyter_nbformat/v4/tests/nbexamples.py similarity index 100% rename from IPython/nbformat/v4/tests/nbexamples.py rename to jupyter_nbformat/v4/tests/nbexamples.py diff --git a/IPython/nbformat/v4/tests/test_convert.py b/jupyter_nbformat/v4/tests/test_convert.py similarity index 100% rename from IPython/nbformat/v4/tests/test_convert.py rename to jupyter_nbformat/v4/tests/test_convert.py diff --git a/IPython/nbformat/v4/tests/test_json.py b/jupyter_nbformat/v4/tests/test_json.py similarity index 100% rename from IPython/nbformat/v4/tests/test_json.py rename to jupyter_nbformat/v4/tests/test_json.py diff --git a/IPython/nbformat/v4/tests/test_nbbase.py b/jupyter_nbformat/v4/tests/test_nbbase.py similarity index 100% rename from IPython/nbformat/v4/tests/test_nbbase.py rename to jupyter_nbformat/v4/tests/test_nbbase.py diff --git a/IPython/nbformat/v4/tests/test_validate.py b/jupyter_nbformat/v4/tests/test_validate.py similarity index 100% rename from IPython/nbformat/v4/tests/test_validate.py rename to jupyter_nbformat/v4/tests/test_validate.py diff --git a/IPython/nbformat/validator.py b/jupyter_nbformat/validator.py similarity index 100% rename from IPython/nbformat/validator.py rename to jupyter_nbformat/validator.py diff --git a/setupbase.py b/setupbase.py index 382510a..481d557 100644 --- a/setupbase.py +++ b/setupbase.py @@ -196,11 +196,11 @@ def find_package_data(): 'preprocessors/tests/files/*.*', ], 'IPython.nbconvert.filters' : ['marked.js'], - 'IPython.nbformat' : [ - 'tests/*.ipynb', - 'v3/nbformat.v3.schema.json', - 'v4/nbformat.v4.schema.json', - ], + # 'IPython.nbformat' : [ + # 'tests/*.ipynb', + # 'v3/nbformat.v3.schema.json', + # 'v4/nbformat.v4.schema.json', + # ], 'IPython.kernel': ['resources/*.*'], }