frontend.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. """
  2. Shim to maintain backwards compatibility with old frontend imports.
  3. We have moved all contents of the old `frontend` subpackage into top-level
  4. subpackages (`html`, `qt` and `terminal`), and flattened the notebook into
  5. just `IPython.html`, formerly `IPython.frontend.html.notebook`.
  6. This will let code that was making `from IPython.frontend...` calls continue
  7. working, though a warning will be printed.
  8. """
  9. # Copyright (c) IPython Development Team.
  10. # Distributed under the terms of the Modified BSD License.
  11. import sys
  12. from warnings import warn
  13. from IPython.utils.shimmodule import ShimModule, ShimWarning
  14. warn("The top-level `frontend` package has been deprecated since IPython 1.0. "
  15. "All its subpackages have been moved to the top `IPython` level.", ShimWarning)
  16. # Unconditionally insert the shim into sys.modules so that further import calls
  17. # trigger the custom attribute access above
  18. sys.modules['IPython.frontend.html.notebook'] = ShimModule(
  19. src='IPython.frontend.html.notebook', mirror='IPython.html')
  20. sys.modules['IPython.frontend'] = ShimModule(
  21. src='IPython.frontend', mirror='IPython')