__init__.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """
  2. Python Markdown
  3. A Python implementation of John Gruber's Markdown.
  4. Documentation: https://python-markdown.github.io/
  5. GitHub: https://github.com/Python-Markdown/markdown/
  6. PyPI: https://pypi.org/project/Markdown/
  7. Started by Manfred Stienstra (http://www.dwerg.net/).
  8. Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
  9. Currently maintained by Waylan Limberg (https://github.com/waylan),
  10. Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
  11. Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
  12. Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
  13. Copyright 2004 Manfred Stienstra (the original version)
  14. License: BSD (see LICENSE.md for details).
  15. """
  16. import sys
  17. # TODO: Remove this check at some point in the future.
  18. # (also remove flake8's 'ignore E402' comments below)
  19. if sys.version_info[0] < 3: # pragma: no cover
  20. raise ImportError('A recent version of Python 3 is required.')
  21. from .core import Markdown, markdown, markdownFromFile # noqa: E402
  22. from .util import PY37 # noqa: E402
  23. from .pep562 import Pep562 # noqa: E402
  24. from .__meta__ import __version__, __version_info__ # noqa: E402
  25. import warnings # noqa: E402
  26. # For backward compatibility as some extensions expect it...
  27. from .extensions import Extension # noqa
  28. __all__ = ['Markdown', 'markdown', 'markdownFromFile']
  29. __deprecated__ = {
  30. "version": ("__version__", __version__),
  31. "version_info": ("__version_info__", __version_info__)
  32. }
  33. def __getattr__(name):
  34. """Get attribute."""
  35. deprecated = __deprecated__.get(name)
  36. if deprecated:
  37. warnings.warn(
  38. "'{}' is deprecated. Use '{}' instead.".format(name, deprecated[0]),
  39. category=DeprecationWarning,
  40. stacklevel=(3 if PY37 else 4)
  41. )
  42. return deprecated[1]
  43. raise AttributeError("module '{}' has no attribute '{}'".format(__name__, name))
  44. if not PY37:
  45. Pep562(__name__)