/opt/imunify360/venv/lib/python3.11/site-packages/jinja2
NameSizeModeActions
__pycache__/-0755rm
asyncfilters.py42500644editdlrm
asyncsupport.py72090644editdlrm
bccache.py121390644editdlrm
compiler.py662840644editdlrm
constants.py14580644editdlrm
debug.py85290644editdlrm
defaults.py11260644editdlrm
environment.py506290644editdlrm
exceptions.py54250644editdlrm
ext.py264410644editdlrm
filters.py414150644editdlrm
idtracking.py92110644editdlrm
lexer.py303310644editdlrm
loaders.py176660644editdlrm
meta.py41310644editdlrm
nativetypes.py27530644editdlrm
nodes.py310950644editdlrm
optimizer.py14570644editdlrm
parser.py356600644editdlrm
runtime.py306180644editdlrm
sandbox.py171270644editdlrm
tests.py47990644editdlrm
utils.py225220644editdlrm
visitor.py32400644editdlrm
_compat.py31910644editdlrm
_identifier.py17750644editdlrm
__init__.py15490644editdlrm
Edit: /opt/imunify360/venv/lib/python3.11/site-packages/jinja2/optimizer.py (1457B)
# -*- coding: utf-8 -*- """The optimizer tries to constant fold expressions and modify the AST in place so that it should be faster to evaluate. Because the AST does not contain all the scoping information and the compiler has to find that out, we cannot do all the optimizations we want. For example, loop unrolling doesn't work because unrolled loops would have a different scope. The solution would be a second syntax tree that stored the scoping rules. """ from . import nodes from .visitor import NodeTransformer def optimize(node, environment): """The context hint can be used to perform an static optimization based on the context given.""" optimizer = Optimizer(environment) return optimizer.visit(node) class Optimizer(NodeTransformer): def __init__(self, environment): self.environment = environment def generic_visit(self, node, *args, **kwargs): node = super(Optimizer, self).generic_visit(node, *args, **kwargs) # Do constant folding. Some other nodes besides Expr have # as_const, but folding them causes errors later on. if isinstance(node, nodes.Expr): try: return nodes.Const.from_untrusted( node.as_const(args[0] if args else None), lineno=node.lineno, environment=self.environment, ) except nodes.Impossible: pass return node