003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/jinja2
usr
/
local
/
lib
/
python3.8
/
site-packages
/
jinja2
/
📁
..
📄
__init__.py
(2.15 KB)
📁
__pycache__
📄
_identifier.py
(1.73 KB)
📄
async_utils.py
(1.71 KB)
📄
bccache.py
(12.38 KB)
📄
compiler.py
(70.36 KB)
📄
constants.py
(1.4 KB)
📄
debug.py
(9.02 KB)
📄
defaults.py
(1.24 KB)
📄
environment.py
(60.13 KB)
📄
exceptions.py
(4.95 KB)
📄
ext.py
(31.37 KB)
📄
filters.py
(51.34 KB)
📄
idtracking.py
(10.46 KB)
📄
lexer.py
(29.22 KB)
📄
loaders.py
(21.83 KB)
📄
meta.py
(4.29 KB)
📄
nativetypes.py
(3.59 KB)
📄
nodes.py
(33.7 KB)
📄
optimizer.py
(1.61 KB)
📄
parser.py
(38.83 KB)
📄
py.typed
(0 B)
📄
runtime.py
(34.19 KB)
📄
sandbox.py
(14.26 KB)
📄
tests.py
(5.77 KB)
📄
utils.py
(26.33 KB)
📄
visitor.py
(3.49 KB)
Editing: async_utils.py
import inspect import typing as t 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) @wraps(normal_func) 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 async def auto_await(value: t.Union[t.Awaitable["V"], "V"]) -> "V": 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)]
Upload File
Create Folder