-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Jinja from Chromium 114.0.5735.358
Issue: 326748668 Reviewed-on: #3368
- Loading branch information
Showing
36 changed files
with
5,040 additions
and
4,045 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Jinja is a template engine written in pure Python. It provides a | ||
non-XML syntax that supports inline expressions and an optional | ||
sandboxed environment. | ||
""" | ||
from markupsafe import escape | ||
from markupsafe import Markup | ||
from .bccache import BytecodeCache as BytecodeCache | ||
from .bccache import FileSystemBytecodeCache as FileSystemBytecodeCache | ||
from .bccache import MemcachedBytecodeCache as MemcachedBytecodeCache | ||
from .environment import Environment as Environment | ||
from .environment import Template as Template | ||
from .exceptions import TemplateAssertionError as TemplateAssertionError | ||
from .exceptions import TemplateError as TemplateError | ||
from .exceptions import TemplateNotFound as TemplateNotFound | ||
from .exceptions import TemplateRuntimeError as TemplateRuntimeError | ||
from .exceptions import TemplatesNotFound as TemplatesNotFound | ||
from .exceptions import TemplateSyntaxError as TemplateSyntaxError | ||
from .exceptions import UndefinedError as UndefinedError | ||
from .loaders import BaseLoader as BaseLoader | ||
from .loaders import ChoiceLoader as ChoiceLoader | ||
from .loaders import DictLoader as DictLoader | ||
from .loaders import FileSystemLoader as FileSystemLoader | ||
from .loaders import FunctionLoader as FunctionLoader | ||
from .loaders import ModuleLoader as ModuleLoader | ||
from .loaders import PackageLoader as PackageLoader | ||
from .loaders import PrefixLoader as PrefixLoader | ||
from .runtime import ChainableUndefined as ChainableUndefined | ||
from .runtime import DebugUndefined as DebugUndefined | ||
from .runtime import make_logging_undefined as make_logging_undefined | ||
from .runtime import StrictUndefined as StrictUndefined | ||
from .runtime import Undefined as Undefined | ||
from .utils import clear_caches as clear_caches | ||
from .utils import is_undefined as is_undefined | ||
from .utils import pass_context as pass_context | ||
from .utils import pass_environment as pass_environment | ||
from .utils import pass_eval_context as pass_eval_context | ||
from .utils import select_autoescape as select_autoescape | ||
|
||
from .bccache import BytecodeCache | ||
from .bccache import FileSystemBytecodeCache | ||
from .bccache import MemcachedBytecodeCache | ||
from .environment import Environment | ||
from .environment import Template | ||
from .exceptions import TemplateAssertionError | ||
from .exceptions import TemplateError | ||
from .exceptions import TemplateNotFound | ||
from .exceptions import TemplateRuntimeError | ||
from .exceptions import TemplatesNotFound | ||
from .exceptions import TemplateSyntaxError | ||
from .exceptions import UndefinedError | ||
from .filters import contextfilter | ||
from .filters import environmentfilter | ||
from .filters import evalcontextfilter | ||
from .loaders import BaseLoader | ||
from .loaders import ChoiceLoader | ||
from .loaders import DictLoader | ||
from .loaders import FileSystemLoader | ||
from .loaders import FunctionLoader | ||
from .loaders import ModuleLoader | ||
from .loaders import PackageLoader | ||
from .loaders import PrefixLoader | ||
from .runtime import ChainableUndefined | ||
from .runtime import DebugUndefined | ||
from .runtime import make_logging_undefined | ||
from .runtime import StrictUndefined | ||
from .runtime import Undefined | ||
from .utils import clear_caches | ||
from .utils import contextfunction | ||
from .utils import environmentfunction | ||
from .utils import evalcontextfunction | ||
from .utils import is_undefined | ||
from .utils import select_autoescape | ||
|
||
__version__ = "2.11.3" | ||
__version__ = "3.1.2" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import inspect | ||
import typing as t | ||
from functools import WRAPPER_ASSIGNMENTS | ||
from functools import wraps | ||
|
||
from .utils import _PassArg | ||
from .utils import pass_eval_context | ||
|
||
V = t.TypeVar("V") | ||
|
||
|
||
def async_variant(normal_func): # type: ignore | ||
def decorator(async_func): # type: ignore | ||
pass_arg = _PassArg.from_obj(normal_func) | ||
need_eval_context = pass_arg is None | ||
|
||
if pass_arg is _PassArg.environment: | ||
|
||
def is_async(args: t.Any) -> bool: | ||
return t.cast(bool, args[0].is_async) | ||
|
||
else: | ||
|
||
def is_async(args: t.Any) -> bool: | ||
return t.cast(bool, args[0].environment.is_async) | ||
|
||
# Take the doc and annotations from the sync function, but the | ||
# name from the async function. Pallets-Sphinx-Themes | ||
# build_function_directive expects __wrapped__ to point to the | ||
# sync function. | ||
async_func_attrs = ("__module__", "__name__", "__qualname__") | ||
normal_func_attrs = tuple(set(WRAPPER_ASSIGNMENTS).difference(async_func_attrs)) | ||
|
||
@wraps(normal_func, assigned=normal_func_attrs) | ||
@wraps(async_func, assigned=async_func_attrs, updated=()) | ||
def wrapper(*args, **kwargs): # type: ignore | ||
b = is_async(args) | ||
|
||
if need_eval_context: | ||
args = args[1:] | ||
|
||
if b: | ||
return async_func(*args, **kwargs) | ||
|
||
return normal_func(*args, **kwargs) | ||
|
||
if need_eval_context: | ||
wrapper = pass_eval_context(wrapper) | ||
|
||
wrapper.jinja_async_variant = True | ||
return wrapper | ||
|
||
return decorator | ||
|
||
|
||
_common_primitives = {int, float, bool, str, list, dict, tuple, type(None)} | ||
|
||
|
||
async def auto_await(value: t.Union[t.Awaitable["V"], "V"]) -> "V": | ||
# Avoid a costly call to isawaitable | ||
if type(value) in _common_primitives: | ||
return t.cast("V", value) | ||
|
||
if inspect.isawaitable(value): | ||
return await t.cast("t.Awaitable[V]", value) | ||
|
||
return t.cast("V", value) | ||
|
||
|
||
async def auto_aiter( | ||
iterable: "t.Union[t.AsyncIterable[V], t.Iterable[V]]", | ||
) -> "t.AsyncIterator[V]": | ||
if hasattr(iterable, "__aiter__"): | ||
async for item in t.cast("t.AsyncIterable[V]", iterable): | ||
yield item | ||
else: | ||
for item in t.cast("t.Iterable[V]", iterable): | ||
yield item | ||
|
||
|
||
async def auto_to_list( | ||
value: "t.Union[t.AsyncIterable[V], t.Iterable[V]]", | ||
) -> t.List["V"]: | ||
return [x async for x in auto_aiter(value)] |
Oops, something went wrong.