관리-도구
편집 파일: nodes.cpython-39.opt-1.pyc
a �����`wy������������������� ���@���sP��d�Z�ddlZddlmZ�ddlmZ�ddlmZ�ddlmZ�ddlm Z �dd lm Z �ejejej ejejejejd �Zejejejd�Zejejejejejejdd ��dd ��d�ZG�dd��de�ZG�dd��de �Z!G�dd��de"�Z#dd��Z$G�dd��de e!e"��Z%G�dd��de%�Z&G�dd��de%�Z'G�dd��de%�Z(G�d d!��d!e&�Z)G�d"d#��d#e&�Z*G�d$d%��d%e&�Z+G�d&d'��d'e&�Z,G�d(d)��d)e&�Z-G�d*d+��d+e&�Z.G�d,d-��d-e&�Z/G�d.d/��d/e&�Z0G�d0d1��d1e&�Z1G�d2d3��d3e&�Z2G�d4d5��d5e&�Z3G�d6d7��d7e&�Z4G�d8d9��d9e&�Z5G�d:d;��d;e&�Z6G�d<d=��d=e&�Z7G�d>d?��d?e%�Z8G�d@dA��dAe8�Z9G�dBdC��dCe8�Z:G�dDdE��dEe8�Z;G�dFdG��dGe8�Z<G�dHdI��dIe8�Z=G�dJdK��dKe=�Z>G�dLdM��dMe=�Z?G�dNdO��dOe=�Z@G�dPdQ��dQe=�ZAG�dRdS��dSe=�ZBG�dTdU��dUe'�ZCG�dVdW��dWe'�ZDG�dXdY��dYe8�ZEdZd[��ZFG�d\d]��d]e8�ZGG�d^d_��d_e8�ZHG�d`da��dae8�ZIG�dbdc��dce8�ZJG�ddde��dee8�ZKG�dfdg��dge8�ZLG�dhdi��die8�ZMG�djdk��dke8�ZNG�dldm��dme'�ZOG�dndo��doe9�ZRG�dpdq��dqe9�ZSG�drds��dse9�ZTG�dtdu��due9�ZUG�dvdw��dwe9�ZVG�dxdy��dye9�ZWG�dzd{��d{e9�ZXG�d|d}��d}e9�ZYG�d~d��de9�ZZG�d�d���d�e:�Z[G�d�d���d�e:�Z\G�d�d���d�e:�Z]G�d�d���d�e8�Z^G�d�d���d�e8�Z_G�d�d���d�e8�Z`G�d�d���d�e8�ZaG�d�d���d�e8�ZbG�d�d���d�e8�ZcG�d�d���d�e8�ZdG�d�d���d�e8�ZeG�d�d���d�e&�ZfG�d�d���d�e&�ZgG�d�d���d�e&�ZhG�d�d���d�e&�ZiG�d�d���d�e&�ZjG�d�d���d�ej�Zkd�d���Zlemel�e!_n[ldS�)�z�AST nodes generated by the parser for the compiler. Also provides some node tree helper functions used by the parser and compiler in order to normalize nodes. �����N)�deque)�Markup����)�izip)�PY2)� text_type)�with_metaclass)�*�/�//�**�%�+�-)�notr���r���c�����������������C���s���|�|v�S��N����a�br���r����0/usr/lib/python3.9/site-packages/jinja2/nodes.py�<lambda>#��������r���c�����������������C���s���|�|vS�r���r���r���r���r���r���r���$���r���)�eq�ne�gtZgteq�ltZlteq�inZnotinc�������������������@���s���e�Zd�ZdZdS�)� Impossiblez8Raised if the node could not perform a requested action.N��__name__� __module__�__qualname__�__doc__r���r���r���r���r���(���s���r���c�������������������@���s���e�Zd�ZdZdd��ZdS�)�NodeTypez�A metaclass for nodes that handles the field and attribute inheritance. fields and attributes from the parent class are automatically forwarded to the child.c�����������������C���s^���dD�]<}g�}|��t|d�|d���|��|�|d���t|�||<�q|�dd��t�|�|||�S�)N)�fields� attributesr���r����abstractF)�extend�getattr�get�tuple� setdefault�type�__new__)Zmcs�name�bases�d�attrZstorager���r���r���r.���1���s����zNodeType.__new__N)r ���r!���r"���r#���r.���r���r���r���r���r$���,���s���r$���c�������������������@���s*���e�Zd�ZdZd dd�Zdd��Zdd��ZdS�) �EvalContextzcHolds evaluation time information. Custom attributes can be attached to it in extensions. Nc�����������������C���s0���||�_�t|j�r|�|�|�_n|j|�_d|�_d�S��NF)�environment�callable� autoescape�volatile)�selfr5���Z template_namer���r���r����__init__B���s ���� zEvalContext.__init__c�����������������C���s ���|�j����S�r���)�__dict__�copy�r9���r���r���r����saveJ���s����zEvalContext.savec�����������������C���s���|�j�����|�j��|��d�S�r���)r;����clear�update)r9����oldr���r���r����revertM���s���� zEvalContext.revert)N)r ���r!���r"���r#���r:���r>���rB���r���r���r���r���r3���=���s��� r3���c�����������������C���s(���|d�u�r$|�j�d�u�rtd��t|�j��S�|S�)NzIif no eval context is passed, the node must have an attached environment.)r5����RuntimeErrorr3���)�node�ctxr���r���r����get_eval_contextR���s���� � rF���c�������������������@���s����e�Zd�ZdZdZdZdZdd��Zddd �Zd d d�Z dd ��Z dd��Zdd��Zd!dd�Z dd��Zdd��Zdd��ZejZdd��Zdd��ZdS�)"�Nodea���Baseclass for all Jinja nodes. There are a number of nodes available of different types. There are four major types: - :class:`Stmt`: statements - :class:`Expr`: expressions - :class:`Helper`: helper nodes - :class:`Template`: the outermost wrapper node All nodes have fields and attributes. Fields may be other nodes, lists, or arbitrary values. Fields are passed to the constructor as regular positional arguments, attributes as keyword arguments. Each node has two attributes: `lineno` (the line number of the node) and `environment`. The `environment` attribute is set at the end of the parsing process for all nodes automatically. r�����linenor5���Tc�����������������O���s����|�j�rtd��|r�t|�t|�j�krh|�js:td|�jj���td|�jjt|�j�t|�j�dkr^dp`df���t|�j|�D�]\}}t|�||��qt|�jD�]}t|�||� |d����q�|r�tdt t|�����d�S�)Nz#abstract nodes are not instantiablez%r takes 0 argumentsz%r takes 0 or %d argument%sr����s��zunknown attribute %r)r'���� TypeError�lenr%���� __class__r ���r����setattrr&����pop�next�iter)r9���r%���r&���r/����argr2���r���r���r���r:���s���s(������� z Node.__init__Nc�������������� ���c���sn���|�j�D�]b}||��u�rdu�s@n�|dur0||vs@|dur||v�rz|t|�|�fV��W�q�tyf���Y�q0�qdS�)aZ��This method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the `exclude` parameter. Both should be sets or tuples of field names. N)r%���r)����AttributeError)r9����exclude�onlyr/���r���r���r����iter_fields����s"���� ������zNode.iter_fieldsc�����������������c���sP���|���||�D�]>\}}t|t�r:|D�]}t|t�r"|V��q"qt|t�r|V��qdS�)z�Iterates over all direct child nodes of the node. This iterates over all fields and yields the values of they are nodes. If the value of a field is a list all the nodes in that list are returned. N)rW���� isinstance�listrG���)r9���rU���rV����_�item�nr���r���r����iter_child_nodes����s���� zNode.iter_child_nodesc�����������������C���s���|���|�D�] }|��S�dS�)ziFind the first node of a given type. If no such node exists the return value is `None`. N)�find_all)r9���� node_type�resultr���r���r����find����s����z Node.findc�����������������c���s8���|�����D�]*}t||�r|V��|�|�D�] }|V��q&qdS�)z�Find all the nodes of a given type. If the type is a tuple, the check is performed for any of the tuple items. N)r]���rX���r^���)r9���r_����childr`���r���r���r���r^�������s ���� z Node.find_allc�����������������C���s:���t�|�g�}|r6|���}d|jv�r&||_|�|�����q |�S�)a��Reset the context of a node and all child nodes. Per default the parser will all generate nodes that have a 'load' context as it's the most common one. This method is used in the parser to set assignment targets and other nodes to a store context. rE���)r����popleftr%���rE���r(���r]���)r9���rE����todorD���r���r���r����set_ctx����s���� zNode.set_ctxFc�����������������C���sH���t�|�g�}|rD|���}d|jv�r4|jdu�s.|r4||_|�|�����q |�S�)z.Set the line numbers of the node and children.rI���N)r���rc���r&���rI���r(���r]���)r9���rI����overriderd���rD���r���r���r���� set_lineno����s���� zNode.set_linenoc�����������������C���s0���t�|�g�}|r,|���}||_|�|�����q |�S�)z"Set the environment for all nodes.)r���rc���r5���r(���r]���)r9���r5���rd���rD���r���r���r����set_environment����s���� zNode.set_environmentc�����������������C���s(���t�|��t�|�u�o&t|�����t|����kS�r���)r-���r+���rW����r9����otherr���r���r����__eq__����s�����zNode.__eq__c�����������������C���s���|���|��S�r���)rk���ri���r���r���r����__ne__����s����zNode.__ne__c��������������������s&���d��j�jd���fdd���jD���f�S�)Nz%s(%s)�, c�����������������3���s"���|�]}d�|t���|d�f�V��qdS�)z%s=%rN)r)���)�.0rS���r=���r���r���� <genexpr>����r���z Node.__repr__.<locals>.<genexpr>)rN���r ����joinr%���r=���r���r=���r����__repr__����s�����z Node.__repr__c��������������������s$������fdd���g����|���d����S�)Nc��������������������s����t�|�t�s��t|����d�S���d|�jj���|�jsB��d��d�S�t|�j�D�]p\}}|rb��d��t|�|�}t�|t �r���d��t|�D�]\}}|r���d����|��q���d��qL��|��qL��d��d�S�)Nz nodes.%s(�)rm����[�]) rX���rG����append�reprrN���r ���r%���� enumerater)���rY���)rD����idxZfield�valuer[�����_dump�bufr���r���r{�������s(���� zNode.dump.<locals>._dumprK���)rp���r=���r���rz���r����dump����s����z Node.dump)NN)NN)F)r ���r!���r"���r#���r%���r&���r'���r:���rW���r]���ra���r^���re���rg���rh���rk���rl����object�__hash__rq���r}���r���r���r���r���rG���^���s"��� rG���c�������������������@���s���e�Zd�ZdZdZdS�)�StmtzBase node for all statements.TN�r ���r!���r"���r#���r'���r���r���r���r���r���� ��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Helperz,Nodes that exist in a specific context only.TNr����r���r���r���r���r������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�TemplatezjNode that represents a template. This must be the outermost node that is passed to the compiler. ��bodyN�r ���r!���r"���r#���r%���r���r���r���r���r������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Outputz�A node that holds multiple expressions which are then printed out. This is used both for the `print` statement and the regular template data. ��nodesNr����r���r���r���r���r������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Extendsz Represents an extends statement.)�templateNr����r���r���r���r���r����&��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Forax��The for loop. `target` is the target for the iteration (usually a :class:`Name` or :class:`Tuple`), `iter` the iterable. `body` is a list of nodes that are used as loop-body, and `else_` a list of nodes for the `else` block. If no else node exists it has to be an empty list. For filtered nodes an expression can be stored as `test`, otherwise `None`. )�targetrR���r�����else_�test� recursiveNr����r���r���r���r���r����,��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Ifz4If `test` is true, `body` is rendered, else `else_`.)r����r����Zelif_r����Nr����r���r���r���r���r����8��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Macroz�A macro definition. `name` is the name of the macro, `args` a list of arguments and `defaults` a list of defaults if there are any. `body` is a list of nodes for the macro body. )r/����args�defaultsr����Nr����r���r���r���r���r����>��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)� CallBlockz�Like a macro without a name but a call instead. `call` is called with the unnamed macro as `caller` argument this node holds. )�callr����r����r����Nr����r���r���r���r���r����G��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�FilterBlockzNode for filter sections.)r�����filterNr����r���r���r���r���r����O��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Withz�Specific node for with statements. In older versions of Jinja the with statement was implemented on the base of the `Scope` node instead. .. versionadded:: 2.9.3 )�targets�valuesr����Nr����r���r���r���r���r����U��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�BlockzA node that represents a block.)r/���r����ZscopedNr����r���r���r���r���r����_��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Includez'A node that represents the include tag.)r�����with_contextZignore_missingNr����r���r���r���r���r����e��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Importz&A node that represents the import tag.)r����r����r����Nr����r���r���r���r���r����k��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)� FromImporta��A node that represents the from import tag. It's important to not pass unsafe names to the name attribute. The compiler translates the attribute lookups directly into getattr calls and does *not* use the subscript callback of the interface. As exported variables may not start with double underscores (which the parser asserts) this is not a problem for regular Jinja code, but if this node is used in an extension extra care must be taken. The list of names may contain tuples if aliases are wanted. )r�����namesr����Nr����r���r���r���r���r����q��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�ExprStmtzAA statement that evaluates an expression and discards the result.�rD���Nr����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Assignz"Assigns an expression to a target.)r����rD���Nr����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�AssignBlockzAssigns a block to a target.)r����r����r����Nr����r���r���r���r���r�������s���r����c�������������������@���s&���e�Zd�ZdZdZddd�Zdd��ZdS�) �ExprzBaseclass for all expressions.TNc�����������������C���s ���t����dS�)an��Return the value of the expression as constant or raise :exc:`Impossible` if this was not possible. An :class:`EvalContext` can be provided, if none is given a default context is created which requires the nodes to have an attached environment. .. versionchanged:: 2.4 the `eval_ctx` parameter was added. N)r����r9����eval_ctxr���r���r����as_const���s����z Expr.as_constc�����������������C���s���dS�)z8Check if it's possible to assign something to this node.Fr���r=���r���r���r���� can_assign���s����zExpr.can_assign)N)r ���r!���r"���r#���r'���r����r����r���r���r���r���r�������s��� r����c�������������������@���s&���e�Zd�ZdZdZdZdZddd�ZdS�)�BinExprz%Baseclass for all binary expressions.)�left�rightNTc�����������������C���sj���t�|�|�}|�jjr&|�j|�jjv�r&t���t|�j�}z||�j�|�|�j �|��W�S��t yd���t���Y�n0�d�S�r���)rF���r5���� sandboxed�operatorZintercepted_binopsr����_binop_to_funcr����r����r����� Exception�r9���r�����fr���r���r���r�������s���� �� zBinExpr.as_const)N�r ���r!���r"���r#���r%���r����r'���r����r���r���r���r���r�������s ���r����c�������������������@���s&���e�Zd�ZdZdZdZdZddd�ZdS�)� UnaryExprz$Baseclass for all unary expressions.r����NTc�����������������C���s`���t�|�|�}|�jjr&|�j|�jjv�r&t���t|�j�}z||�j�|��W�S��t yZ���t���Y�n0�d�S�r���) rF���r5���r����r����Zintercepted_unopsr���� _uaop_to_funcrD���r����r����r����r���r���r���r�������s���� �� zUnaryExpr.as_const)Nr����r���r���r���r���r�������s ���r����c�������������������@���s���e�Zd�ZdZdZdd��ZdS�)�Namea��Looks up a name or stores a value in a name. The `ctx` of the node can be one of the following values: - `store`: store a value in the name - `load`: load that name - `param`: like `store` but if the name was defined as function parameter. )r/���rE���c�����������������C���s ���|�j�dvS�)N)�trueZfalseZnone�True�False�None�r/���r=���r���r���r���r�������s����zName.can_assignN�r ���r!���r"���r#���r%���r����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZdd��ZdS�)�NSRefz)Reference to a namespace value assignment)r/���r2���c�����������������C���s���dS�)NTr���r=���r���r���r���r�������s����zNSRef.can_assignNr����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�LiteralzBaseclass for literals.TNr����r���r���r���r���r�������s���r����c�������������������@���s,���e�Zd�ZdZdZddd�Zed dd��ZdS�) �Consta��All constant values. The parser will return this node for simple constants such as ``42`` or ``"foo"`` but it can be used to store more complex values such as lists too. Only constants with a safe representation (objects where ``eval(repr(x)) == x`` is true). )ry���Nc�����������������C���sH���|�j�}trDt|�tu�rD|�jjd�rDz|�d�}W�n�tyB���Y�n0�|S�)Nzcompiler.ascii_str�ascii)ry���r���r-���r���r5���Zpolicies�encode�UnicodeError)r9���r�����rvr���r���r���r�������s����� � �zConst.as_constc�����������������C���s(���ddl�m}�||�st���|�|||d�S�)z�Return a const object if the value is representable as constant value in the generated code, otherwise it will raise an `Impossible` exception. r���)� has_safe_reprrH���)Zcompilerr����r���)�clsry���rI���r5���r����r���r���r����from_untrusted ��s����zConst.from_untrusted)N)NN)r ���r!���r"���r#���r%���r�����classmethodr����r���r���r���r���r�������s ��� r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�TemplateDatazA constant template string.)�dataNc�����������������C���s,���t�|�|�}|jrt���|jr&t|�j�S�|�jS�r���)rF���r8���r���r7���r���r����r����r���r���r���r������s���� zTemplateData.as_const)N�r ���r!���r"���r#���r%���r����r���r���r���r���r������s���r����c�������������������@���s&���e�Zd�ZdZdZddd�Zdd��ZdS�) �Tuplez�For loop unpacking and some other things like multiple arguments for subscripts. Like for :class:`Name` `ctx` specifies if the tuple is used for loading the names or storing. )�itemsrE���Nc��������������������s"���t�|������t��fdd�|�jD���S�)Nc�����������������3���s���|�]}|�����V��qd�S�r����r�����rn����x�r����r���r���ro���2��r���z!Tuple.as_const.<locals>.<genexpr>)rF���r+���r����r����r���r����r���r����0��s���� zTuple.as_constc�����������������C���s���|�j�D�]}|���s�dS�qdS�)NFT)r����r����)r9���r[���r���r���r���r����4��s���� zTuple.can_assign)N�r ���r!���r"���r#���r%���r����r����r���r���r���r���r����(��s��� r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�Listz&Any list literal such as ``[1, 2, 3]``�r����Nc��������������������s���t�|��������fdd�|�jD��S�)Nc��������������������s���g�|�]}|������qS�r���r����r����r����r���r���� <listcomp>B��r���z!List.as_const.<locals>.<listcomp>)rF���r����r����r���r����r���r����@��s���� z List.as_const)Nr����r���r���r���r���r����;��s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�DictzeAny dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes. r����Nc��������������������s"���t�|������t��fdd�|�jD���S�)Nc�����������������3���s���|�]}|�����V��qd�S�r���r����r����r����r���r���ro���N��r���z Dict.as_const.<locals>.<genexpr>)rF����dictr����r����r���r����r���r����L��s���� z Dict.as_const)Nr����r���r���r���r���r����E��s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�PairzA key, value pair for dicts.��keyry���Nc�����������������C���s"���t�|�|�}|�j�|�|�j�|�fS�r���)rF���r����r����ry���r����r���r���r���r����V��s���� z Pair.as_const)Nr����r���r���r���r���r����Q��s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�Keywordz>A key, value pair for keyword arguments where key is a string.r����Nc�����������������C���s���t�|�|�}|�j|�j�|�fS�r���)rF���r����ry���r����r����r���r���r���r����`��s���� zKeyword.as_const)Nr����r���r���r���r���r����[��s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�CondExprzZA conditional expression (inline if expression). (``{{ foo if bar else baz }}``) )r�����expr1�expr2Nc�����������������C���s>���t�|�|�}|�j�|�r"|�j�|�S�|�jd�u�r2t���|�j�|�S�r���)rF���r����r����r����r����r���r����r���r���r���r����l��s���� zCondExpr.as_const)Nr����r���r���r���r���r����e��s���r����c��������������������s������fdd�|�j�D��}t��fdd�|�jD���}|�jd�urfz|�|�j������W�n�tyd���t���Y�n0�|�jd�ur�z|� |�j������W�n�ty����t���Y�n0�||fS�)Nc��������������������s���g�|�]}|������qS�r���r����r����r����r���r���r����y��r���z!args_as_const.<locals>.<listcomp>c�����������������3���s���|�]}|�����V��qd�S�r���r����r����r����r���r���ro���z��r���z args_as_const.<locals>.<genexpr>) r����r�����kwargs�dyn_argsr(���r����r����r���� dyn_kwargsr@���)rD���r����r����r����r���r����r���� args_as_constx��s���� r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�Filtera��This node applies a filter on an expression. `name` is the name of the filter, the rest of the fields are the same as for :class:`Call`. If the `node` of a filter is `None` the contents of the last buffer are filtered. Buffers are created by macros and filter blocks. �rD���r/���r����r����r����r����Nc�����������������C���s����t�|�|�}|js|�jd�u�r t���|�jj�|�j�}|d�u�sHt|dd�du�rNt���|jj rht|dd�rht���t |�|�\}}|�d|�j�|���t|dd�du�r�|�d|��nt|dd�du�r�|�d|�j��z||i�|��W�S��t y����t���Y�n0�d�S�)NZ contextfilterFTZasyncfiltervariantr���ZevalcontextfilterZenvironmentfilter)rF���r8���rD���r���r5����filtersr*���r/���r)����is_asyncr�����insertr����r����)r9���r����Zfilter_r����r����r���r���r���r�������s(���� �zFilter.as_const)Nr����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�Testz�Applies a test on an expression. `name` is the name of the test, the rest of the fields are the same as for :class:`Call`. r����Nc�����������������C���sx���|�j�j�|�j�}|d�u�rt���t|�|�}t|�|�\}}|�d|�j� |���z||i�|��W�S��t yr���t���Y�n0�d�S�)Nr���)r5���Ztestsr*���r/���r���rF���r����r����rD���r����r����)r9���r����r����r����r����r���r���r���r�������s���� z Test.as_const)Nr����r���r���r���r���r�������s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Calla/��Calls an expression. `args` is a list of arguments, `kwargs` a list of keyword arguments (list of :class:`Keyword` nodes), and `dyn_args` and `dyn_kwargs` has to be either `None` or a node that is used as node for dynamic positional (``*args``) or keyword (``**kwargs``) arguments. )rD���r����r����r����r����Nr����r���r���r���r���r�������s���r����c�������������������@���s&���e�Zd�ZdZdZddd�Zdd��ZdS�) �Getitemz@Get an attribute or item from an expression and prefer the item.)rD���rS���rE���Nc�����������������C���sX���t�|�|�}|�jdkrt���z |�j�|�j�|�|�j�|��W�S��tyR���t���Y�n0�d�S��N�load) rF���rE���r���r5����getitemrD���r����rS���r����r����r���r���r���r�������s���� �zGetitem.as_constc�����������������C���s���dS�r4���r���r=���r���r���r���r�������s����zGetitem.can_assign)Nr����r���r���r���r���r�������s��� r����c�������������������@���s&���e�Zd�ZdZdZddd�Zdd��ZdS�) �GetattrznGet an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute. )rD���r2���rE���Nc�����������������C���sR���|�j�dkrt���z$t|�|�}|�j�|�j�|�|�j�W�S��tyL���t���Y�n0�d�S�r����) rE���r���rF���r5���r)���rD���r����r2���r����r����r���r���r���r�������s���� zGetattr.as_constc�����������������C���s���dS�r4���r���r=���r���r���r���r�������s����zGetattr.can_assign)Nr����r���r���r���r���r�������s��� r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�Slicez_Represents a slice object. This must only be used as argument for :class:`Subscript`. )�start�stop�stepNc��������������������s4���t�|��������fdd�}t||�j�||�j�||�j��S�)Nc��������������������s���|�d�u�rd�S�|������S�r���r����)�objr����r���r����const��s����zSlice.as_const.<locals>.const)rF����slicer����r����r����)r9���r����r����r���r����r���r������s���� zSlice.as_const)Nr����r���r���r���r���r������s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�ConcatzXConcatenates the list of expressions provided after converting them to unicode. r����Nc��������������������s$���t�|������d���fdd�|�jD���S�)NrK���c�����������������3���s���|�]}t�|�����V��qd�S�r���)r���r����r����r����r���r���ro�����r���z"Concat.as_const.<locals>.<genexpr>)rF���rp���r����r����r���r����r���r������s���� zConcat.as_const)Nr����r���r���r���r���r������s���r����c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�CompareziCompares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s. )�expr�opsNc�����������������C���st���t�|�|�}|�j�|��}}z<|�jD�]0}|j�|�}t|j�||�}|sN�W�dS�|}q"W�n�tyn���t���Y�n0�|S�r4���)rF���r����r����r�����_cmpop_to_func�opr����r���)r9���r����r`���ry���r����Z new_valuer���r���r���r����)��s���� zCompare.as_const)Nr����r���r���r���r���r����"��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Operandz$Holds an operator and an expression.)r����r����Nr����r���r���r���r���r����<��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Mulz(Multiplies the left with the right node.r ���N�r ���r!���r"���r#���r����r���r���r���r���r����K��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�Divz#Divides the left by the right node.r ���Nr����r���r���r���r���r����Q��s���r����c�������������������@���s���e�Zd�ZdZdZdS�)�FloorDivzjDivides the left by the right node and truncates conver the result into an integer by truncating. r���Nr����r���r���r���r���r���W��s���r���c�������������������@���s���e�Zd�ZdZdZdS�)�AddzAdd the left to the right node.r���Nr����r���r���r���r���r��_��s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�Subz&Subtract the right from the left node.r���Nr����r���r���r���r���r��e��s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�ModzLeft modulo right.r ���Nr����r���r���r���r���r��k��s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�PowzLeft to the power of right.r���Nr����r���r���r���r���r��q��s���r��c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�AndzShort circuited AND.�andNc�����������������C���s"���t�|�|�}|�j�|�o |�j�|�S�r����rF���r����r����r����r����r���r���r���r����|��s���� zAnd.as_const)N�r ���r!���r"���r#���r����r����r���r���r���r���r��w��s���r��c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�OrzShort circuited OR.�orNc�����������������C���s"���t�|�|�}|�j�|�p |�j�|�S�r���r��r����r���r���r���r�������s���� zOr.as_const)Nr��r���r���r���r���r �����s���r ��c�������������������@���s���e�Zd�ZdZdZdS�)�NotzNegate the expression.r���Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�NegzMake the expression negative.r���Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�Posz8Make the expression positive (noop for most expressions)r���Nr����r���r���r���r���r �����s���r ��c�������������������@���s���e�Zd�ZdZdZdS�)�EnvironmentAttributez�Loads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment. r����Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�ExtensionAttributez�Returns the attribute of an extension bound to the environment. The identifier is the identifier of the :class:`Extension`. This node is usually constructed by calling the :meth:`~jinja2.ext.Extension.attr` method on an extension. )Z identifierr/���Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�ImportedNamea&��If created with an import name the import name is returned on node access. For example ``ImportedName('cgi.escape')`` returns the `escape` function from the cgi module on evaluation. Imports are optimized by the compiler so there is no need to assign them to local variables. )Z importnameNr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZdd��ZdS�)�InternalNamea7��An internal name in the compiler. You cannot create these nodes yourself but the parser provides a :meth:`~jinja2.parser.Parser.free_identifier` method that creates a new identifier for you. This identifier is not available from the template and is not threated specially by the compiler. r����c�����������������C���s���t�d��d�S�)NzKCan't create internal names. Use the `free_identifier` method on a parser.�rL���r=���r���r���r���r:������s�����zInternalName.__init__N)r ���r!���r"���r#���r%���r:���r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�MarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).�r����Nc�����������������C���s���t�|�|�}t|�j�|��S�r���)rF���r���r����r����r����r���r���r���r�������s���� zMarkSafe.as_const)Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdZddd�ZdS�)�MarkSafeIfAutoescapez�Mark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active. .. versionadded:: 2.5 r��Nc�����������������C���s4���t�|�|�}|jrt���|�j�|�}|jr0t|�S�|S�r���)rF���r8���r���r����r����r7���r���)r9���r����r����r���r���r���r�������s���� zMarkSafeIfAutoescape.as_const)Nr����r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdS�)�ContextReferenceaP��Returns the current template context. It can be used like a :class:`Name` node, with a ``'load'`` ctx and will return the current :class:`~jinja2.runtime.Context` object. Here an example that assigns the current template name to a variable named `foo`:: Assign(Name('foo', ctx='store'), Getattr(ContextReference(), 'name')) This is basically equivalent to using the :func:`~jinja2.contextfunction` decorator when using the high-level API, which causes a reference to the context to be passed as the first argument to a function. Nr���r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdS�)�DerivedContextReferencez�Return the current template context including locals. Behaves exactly like :class:`ContextReference`, but includes local variables, such as from a ``for`` loop. .. versionadded:: 2.11 Nr���r���r���r���r���r�����s���r��c�������������������@���s���e�Zd�ZdZdS�)�ContinuezContinue a loop.Nr���r���r���r���r���r����s���r��c�������������������@���s���e�Zd�ZdZdS�)�Breakz Break a loop.Nr���r���r���r���r���r�� ��s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�ScopezAn artificial scope.r����Nr����r���r���r���r���r����s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�OverlayScopea���An overlay scope for extensions. This is a largely unoptimized scope that however can be used to introduce completely arbitrary variables into a sub scope from a dictionary or dictionary like object. The `context` field has to evaluate to a dictionary object. Example usage:: OverlayScope(context=self.call_method('get_context'), body=[...]) .. versionadded:: 2.10 )�contextr����Nr����r���r���r���r���r����s��� r��c�������������������@���s���e�Zd�ZdZdZdS�)�EvalContextModifiera ��Modifies the eval context. For each option that should be modified, a :class:`Keyword` has to be added to the :attr:`options` list. Example to change the `autoescape` setting:: EvalContextModifier(options=[Keyword('autoescape', Const(True))]) )�optionsNr����r���r���r���r���r��%��s���r��c�������������������@���s���e�Zd�ZdZdZdS�)�ScopedEvalContextModifierz�Modifies the eval context and reverts it later. Works exactly like :class:`EvalContextModifier` but will only modify the :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`. r����Nr����r���r���r���r���r��1��s���r��c������������������O���s���t�d��d�S�)Nzcan't create custom node typesr��)r����r����r���r���r����_failing_new;��s����r ��)or#���r�����collectionsr���Z markupsafer���Z_compatr���r���r���r����mul�truediv�floordiv�pow�mod�add�subr�����not_�pos�negr����r���r���r����ger����ler����r����r���r-���r$���r~���r3���rF���rG���r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r�����sorted�setr����r����r���r��r��r��r��r��r ��r��r��r ��r��r��r��r��r��r��r��r��r��r��r��r��r��r��r ���staticmethodr.���r���r���r���r����<module>���s����� ��- # /