diff options
author | David Lord <davidism@gmail.com> | 2020-01-10 14:40:27 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-01-10 14:59:56 -0800 |
commit | 081f312a127bbdab20ec51be6b5fe0610b9c1948 (patch) | |
tree | 6d7ae37742b199436beb732f9e6c540bb992ae9e | |
parent | 71ec6fd22036860a39fdc4968f6eb4983384c543 (diff) | |
download | jinja2-the-great-rename.tar.gz |
add warning and alias for jinja2the-great-rename
39 files changed, 207 insertions, 15 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 8cae0c7..bf02825 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,4 @@ prune docs/_build graft examples graft ext graft tests +global-exclude *.pyc diff --git a/jinja2-compat/LICENSE.rst b/jinja2-compat/LICENSE.rst new file mode 100644 index 0000000..c37cae4 --- /dev/null +++ b/jinja2-compat/LICENSE.rst @@ -0,0 +1,28 @@ +Copyright 2007 Pallets + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/jinja2-compat/MANIFEST.in b/jinja2-compat/MANIFEST.in new file mode 100644 index 0000000..40c6ac8 --- /dev/null +++ b/jinja2-compat/MANIFEST.in @@ -0,0 +1 @@ +global-exclude *.pyc diff --git a/jinja2-compat/README.rst b/jinja2-compat/README.rst new file mode 100644 index 0000000..b240416 --- /dev/null +++ b/jinja2-compat/README.rst @@ -0,0 +1,9 @@ +The Jinja2 package has been renamed to `Jinja`_. This package provides +compatibility while projects transition to the new name. Imports from +``jinja2`` will be redirected to ``jinja`` and a deprecation warning +will be emitted. + +Projects are advised to require 'Jinja' instead of 'Jinja2' and replace +all imports of ``jinja2`` with ``jinja`` to continue receiving updates. + +.. _Jinja: https://pypi.org/project/Jinja/ diff --git a/jinja2-compat/setup.cfg b/jinja2-compat/setup.cfg new file mode 100644 index 0000000..cf42c63 --- /dev/null +++ b/jinja2-compat/setup.cfg @@ -0,0 +1,5 @@ +[metadata] +license_file = LICENSE.rst + +[bdist_wheel] +universal = true diff --git a/jinja2-compat/setup.py b/jinja2-compat/setup.py new file mode 100644 index 0000000..9edc0d9 --- /dev/null +++ b/jinja2-compat/setup.py @@ -0,0 +1,53 @@ +import io + +from setuptools import find_packages +from setuptools import setup + +with io.open("README.rst", "rt", encoding="utf8") as f: + readme = f.read() + +setup( + name="Jinja2", + version="2.11.0rc1", + url="https://palletsprojects.com/p/jinja/", + project_urls={ + "Documentation": "https://jinja.palletsprojects.com/", + "Code": "https://github.com/pallets/jinja", + "Issue tracker": "https://github.com/pallets/jinja/issues", + }, + license="BSD-3-Clause", + maintainer="Pallets", + maintainer_email="contact@palletsprojects.com", + description=( + "A very fast and expressive template engine. Compatibility" + " package for Jinja2 to Jinja rename." + ), + long_description=readme, + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Markup :: HTML", + ], + packages=find_packages("src"), + package_dir={"": "src"}, + include_package_data=True, + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + install_requires=["Jinja<4.0"], + extras_require={"i18n": ["Babel>=0.8"]}, + entry_points={"babel.extractors": ["jinja2 = jinja2.ext:babel_extract[i18n]"]}, +) diff --git a/jinja2-compat/src/jinja2/__init__.py b/jinja2-compat/src/jinja2/__init__.py new file mode 100644 index 0000000..526ee78 --- /dev/null +++ b/jinja2-compat/src/jinja2/__init__.py @@ -0,0 +1,21 @@ +def _export_jinja(name, ns): + import warnings + from importlib import import_module + + mod_name = "jinja" if not name else ("jinja." + name) + warnings.warn( + "'jinja2' has been renamed to 'jinja'. Import from %r instead." % mod_name, + DeprecationWarning, + stacklevel=3, + ) + mod = import_module(mod_name) + + for key, value in vars(mod).items(): + if not key.startswith("__") or key == "__version__": + ns[key] = value + + if name: + ns.pop("_export_jinja") + + +_export_jinja(None, globals()) diff --git a/jinja2-compat/src/jinja2/_compat.py b/jinja2-compat/src/jinja2/_compat.py new file mode 100644 index 0000000..d0b2d95 --- /dev/null +++ b/jinja2-compat/src/jinja2/_compat.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("_compat", globals()) diff --git a/jinja2-compat/src/jinja2/_identifier.py b/jinja2-compat/src/jinja2/_identifier.py new file mode 100644 index 0000000..64dc1dd --- /dev/null +++ b/jinja2-compat/src/jinja2/_identifier.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("_identifier", globals()) diff --git a/jinja2-compat/src/jinja2/asyncfilters.py b/jinja2-compat/src/jinja2/asyncfilters.py new file mode 100644 index 0000000..e85c81b --- /dev/null +++ b/jinja2-compat/src/jinja2/asyncfilters.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("asyncfilters", globals()) diff --git a/jinja2-compat/src/jinja2/asyncsupport.py b/jinja2-compat/src/jinja2/asyncsupport.py new file mode 100644 index 0000000..bbc91ac --- /dev/null +++ b/jinja2-compat/src/jinja2/asyncsupport.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("asyncsupport", globals()) diff --git a/jinja2-compat/src/jinja2/bccache.py b/jinja2-compat/src/jinja2/bccache.py new file mode 100644 index 0000000..15164f1 --- /dev/null +++ b/jinja2-compat/src/jinja2/bccache.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("bccache", globals()) diff --git a/jinja2-compat/src/jinja2/compiler.py b/jinja2-compat/src/jinja2/compiler.py new file mode 100644 index 0000000..d198e0b --- /dev/null +++ b/jinja2-compat/src/jinja2/compiler.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("compiler", globals()) diff --git a/jinja2-compat/src/jinja2/constants.py b/jinja2-compat/src/jinja2/constants.py new file mode 100644 index 0000000..0026675 --- /dev/null +++ b/jinja2-compat/src/jinja2/constants.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("constants", globals()) diff --git a/jinja2-compat/src/jinja2/debug.py b/jinja2-compat/src/jinja2/debug.py new file mode 100644 index 0000000..6fa47bc --- /dev/null +++ b/jinja2-compat/src/jinja2/debug.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("debug", globals()) diff --git a/jinja2-compat/src/jinja2/defaults.py b/jinja2-compat/src/jinja2/defaults.py new file mode 100644 index 0000000..e3bece6 --- /dev/null +++ b/jinja2-compat/src/jinja2/defaults.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("defaults", globals()) diff --git a/jinja2-compat/src/jinja2/environment.py b/jinja2-compat/src/jinja2/environment.py new file mode 100644 index 0000000..5062aba --- /dev/null +++ b/jinja2-compat/src/jinja2/environment.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("environment", globals()) diff --git a/jinja2-compat/src/jinja2/exceptions.py b/jinja2-compat/src/jinja2/exceptions.py new file mode 100644 index 0000000..3ad241e --- /dev/null +++ b/jinja2-compat/src/jinja2/exceptions.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("exceptions", globals()) diff --git a/jinja2-compat/src/jinja2/ext.py b/jinja2-compat/src/jinja2/ext.py new file mode 100644 index 0000000..923754e --- /dev/null +++ b/jinja2-compat/src/jinja2/ext.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("ext", globals()) diff --git a/jinja2-compat/src/jinja2/filters.py b/jinja2-compat/src/jinja2/filters.py new file mode 100644 index 0000000..9517e64 --- /dev/null +++ b/jinja2-compat/src/jinja2/filters.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("filters", globals()) diff --git a/jinja2-compat/src/jinja2/idtracking.py b/jinja2-compat/src/jinja2/idtracking.py new file mode 100644 index 0000000..755ef1b --- /dev/null +++ b/jinja2-compat/src/jinja2/idtracking.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("idtracking", globals()) diff --git a/jinja2-compat/src/jinja2/lexer.py b/jinja2-compat/src/jinja2/lexer.py new file mode 100644 index 0000000..e69c99c --- /dev/null +++ b/jinja2-compat/src/jinja2/lexer.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("lexer", globals()) diff --git a/jinja2-compat/src/jinja2/loaders.py b/jinja2-compat/src/jinja2/loaders.py new file mode 100644 index 0000000..3616eee --- /dev/null +++ b/jinja2-compat/src/jinja2/loaders.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("loaders", globals()) diff --git a/jinja2-compat/src/jinja2/meta.py b/jinja2-compat/src/jinja2/meta.py new file mode 100644 index 0000000..406d047 --- /dev/null +++ b/jinja2-compat/src/jinja2/meta.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("meta", globals()) diff --git a/jinja2-compat/src/jinja2/nativetypes.py b/jinja2-compat/src/jinja2/nativetypes.py new file mode 100644 index 0000000..60e5705 --- /dev/null +++ b/jinja2-compat/src/jinja2/nativetypes.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("nativetypes", globals()) diff --git a/jinja2-compat/src/jinja2/nodes.py b/jinja2-compat/src/jinja2/nodes.py new file mode 100644 index 0000000..6bfe778 --- /dev/null +++ b/jinja2-compat/src/jinja2/nodes.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("nodes", globals()) diff --git a/jinja2-compat/src/jinja2/optimizer.py b/jinja2-compat/src/jinja2/optimizer.py new file mode 100644 index 0000000..7ca0929 --- /dev/null +++ b/jinja2-compat/src/jinja2/optimizer.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("optimizer", globals()) diff --git a/jinja2-compat/src/jinja2/parser.py b/jinja2-compat/src/jinja2/parser.py new file mode 100644 index 0000000..8b4cdfe --- /dev/null +++ b/jinja2-compat/src/jinja2/parser.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("parser", globals()) diff --git a/jinja2-compat/src/jinja2/runtime.py b/jinja2-compat/src/jinja2/runtime.py new file mode 100644 index 0000000..d218cc7 --- /dev/null +++ b/jinja2-compat/src/jinja2/runtime.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("runtime", globals()) diff --git a/jinja2-compat/src/jinja2/sandbox.py b/jinja2-compat/src/jinja2/sandbox.py new file mode 100644 index 0000000..64d6dd9 --- /dev/null +++ b/jinja2-compat/src/jinja2/sandbox.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("sandbox", globals()) diff --git a/jinja2-compat/src/jinja2/tests.py b/jinja2-compat/src/jinja2/tests.py new file mode 100644 index 0000000..2892b2b --- /dev/null +++ b/jinja2-compat/src/jinja2/tests.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("tests", globals()) diff --git a/jinja2-compat/src/jinja2/utils.py b/jinja2-compat/src/jinja2/utils.py new file mode 100644 index 0000000..b870766 --- /dev/null +++ b/jinja2-compat/src/jinja2/utils.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("utils", globals()) diff --git a/jinja2-compat/src/jinja2/visitor.py b/jinja2-compat/src/jinja2/visitor.py new file mode 100644 index 0000000..c236087 --- /dev/null +++ b/jinja2-compat/src/jinja2/visitor.py @@ -0,0 +1,3 @@ +from . import _export_jinja + +_export_jinja("visitor", globals()) @@ -20,8 +20,6 @@ setup( "Issue tracker": "https://github.com/pallets/jinja/issues", }, license="BSD-3-Clause", - author="Armin Ronacher", - author_email="armin.ronacher@active-4.com", maintainer="Pallets", maintainer_email="contact@palletsprojects.com", description="A very fast and expressive template engine.", @@ -39,6 +37,7 @@ setup( "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", diff --git a/src/jinja/__init__.py b/src/jinja/__init__.py index 9c4c9cf..d758a5b 100644 --- a/src/jinja/__init__.py +++ b/src/jinja/__init__.py @@ -40,4 +40,4 @@ from .utils import is_undefined from .utils import Markup from .utils import select_autoescape -__version__ = "2.11.0.dev0" +__version__ = "2.11.0rc1" diff --git a/src/jinja/compiler.py b/src/jinja/compiler.py index 88b4988..f52d788 100644 --- a/src/jinja/compiler.py +++ b/src/jinja/compiler.py @@ -712,7 +712,7 @@ class CodeGenerator(NodeVisitor): assert frame is None, "no root frame allowed" eval_ctx = EvalContext(self.environment, self.name) - from .runtime import __all__ as exported + from .runtime import exported self.writeline("from __future__ import %s" % ", ".join(code_features)) self.writeline("from jinja.runtime import " + ", ".join(exported)) diff --git a/src/jinja/defaults.py b/src/jinja/defaults.py index b5d5f4e..8e0e7d7 100644 --- a/src/jinja/defaults.py +++ b/src/jinja/defaults.py @@ -42,6 +42,3 @@ DEFAULT_POLICIES = { "json.dumps_kwargs": {"sort_keys": True}, "ext.i18n.trimmed": False, } - -# export all constants -__all__ = tuple(x for x in locals().keys() if x.isupper()) diff --git a/src/jinja/runtime.py b/src/jinja/runtime.py index f6d58a6..d178e41 100644 --- a/src/jinja/runtime.py +++ b/src/jinja/runtime.py @@ -4,7 +4,7 @@ import sys from itertools import chain from types import MethodType -from markupsafe import escape +from markupsafe import escape # noqa: F401 from markupsafe import Markup from markupsafe import soft_unicode @@ -17,19 +17,19 @@ from ._compat import PY2 from ._compat import string_types from ._compat import text_type from ._compat import with_metaclass -from .exceptions import TemplateNotFound -from .exceptions import TemplateRuntimeError +from .exceptions import TemplateNotFound # noqa: F401 +from .exceptions import TemplateRuntimeError # noqa: F401 from .exceptions import UndefinedError from .nodes import EvalContext from .utils import concat from .utils import evalcontextfunction from .utils import internalcode from .utils import missing -from .utils import Namespace +from .utils import Namespace # noqa: F401 from .utils import object_type_repr # these variables are exported to the template runtime -__all__ = [ +exported = [ "LoopContext", "TemplateReference", "Macro", diff --git a/tests/test_bytecode_cache.py b/tests/test_bytecode_cache.py index 6a6173a..51c2dcb 100644 --- a/tests/test_bytecode_cache.py +++ b/tests/test_bytecode_cache.py @@ -9,9 +9,9 @@ from jinja.exceptions import TemplateNotFound @pytest.fixture -def env(package_loader): - bytecode_cache = FileSystemBytecodeCache() - return Environment(loader=package_loader, bytecode_cache=bytecode_cache,) +def env(package_loader, tmp_path): + bytecode_cache = FileSystemBytecodeCache(str(tmp_path)) + return Environment(loader=package_loader, bytecode_cache=bytecode_cache) @pytest.mark.byte_code_cache |