AlkantarClanX12

Your IP : 18.119.142.210


Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/ast.cpython-38.pyc

U

i�f"K�@s�dZddlTd=ddd�dd	�Zd
d�Zd>d
d�Zdd�Zdd�Zd?dd�Zdd�Zdd�Z	d@dd�Z
dd�Zdd�Zdd �d!d"�Z
d#d$�ZGd%d&�d&e�ZGd'd(�d(e�Zd)d*�Zd+d,�Zeee�e_eee�e_Gd-d.�d.e�Zd/d0�ZGd1d2�d2eed3�ZGd4d5�d5eed3�ZGd6d7�d7eed3�ZGd8d9�d9eed3�ZGd:d;�d;eed3�Zee e!e"fee#fee$feed�e%feed<�fiZ&ee%fiZ'e%d9ed�d9e d2e!d2e"d2e#d5e$d7ed<�d;iZ(dS)AaH
    ast
    ~~~

    The `ast` module helps Python applications to process trees of the Python
    abstract syntax grammar.  The abstract syntax itself might change with
    each Python release; this module helps to find out programmatically what
    the current grammar looks like and allows modifications of it.

    An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
    a flag to the `compile()` builtin function or by using the `parse()`
    function from this module.  The result will be a tree of objects whose
    classes all inherit from `ast.AST`.

    A modified abstract syntax tree can be compiled into a Python code object
    using the built-in `compile()` function.

    Additionally various helper functions are provided that make working with
    the trees simpler.  The main intention of the helper functions and this
    module in general is to provide an easy to use interface for libraries
    that work tightly with the python syntax (template engines for example).


    :copyright: Copyright 2008 by Armin Ronacher.
    :license: Python License.
�)�*�	<unknown>�execFN)�
type_comments�feature_versioncCsRt}|r|tO}t|t�r4|\}}|dks.t�|}n|dkr@d}t|||||d�S)z�
    Parse the source into an AST node.
    Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
    Pass type_comments=True to get back type comments where the syntax allows.
    �N���)�_feature_version)Z
PyCF_ONLY_ASTZPyCF_TYPE_COMMENTS�
isinstance�tuple�AssertionError�compile)�source�filename�moderr�flags�major�minor�r�(/opt/alt/python38/lib64/python3.8/ast.py�parses

�rcs`t|t�rt|dd�}t|t�r&|j}dd���fdd���fdd������fd	d
���|�S)a
    Safely evaluate an expression node or a string containing a Python
    expression.  The string or node provided may only consist of the following
    Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
    sets, booleans, and None.
    �eval)rcSstd|����dS)Nzmalformed node or string: )�
ValueError��noderrr�_raise_malformed_node>sz+literal_eval.<locals>._raise_malformed_nodecs,t|t�rt|j�tttfkr&�|�|jS�N)r
�Constant�type�value�int�float�complexr)rrr�_convert_num@sz"literal_eval.<locals>._convert_numcsDt|t�r<t|jttf�r<�|j�}t|jt�r6|
S|S�|�Sr)r
ZUnaryOp�opZUAddZUSub�operand)rr%)r#rr�_convert_signed_numDs
z)literal_eval.<locals>._convert_signed_numcst|t�r|jSt|t�r*tt�|j��St|t�rDtt�|j��St|t	�r^t
t�|j��St|t�r�t|j
�t|j�kr��|�ttt�|j
�t�|j���St|t��rt|jttf��r�|j�}�|j�}t|ttf��rt|t��rt|jt��r||S||S�|�Sr)r
rrZTupler�mapZeltsZList�list�Set�setZDict�len�keys�values�dict�zipZBinOpr$ZAddZSub�left�rightr r!r")rr0r1��_convertr#r&rrrr3Ls,





�

zliteral_eval.<locals>._convert)r
�strrZ
Expression�body)Znode_or_stringrr2r�literal_eval3s

r6Tcs2���fdd��t|t�s*td|jj���|�S)a�
    Return a formatted dump of the tree in node.  This is mainly useful for
    debugging purposes.  If annotate_fields is true (by default),
    the returned string will show the names and the values for fields.
    If annotate_fields is false, the result string will be more compact by
    omitting unambiguous field names.  Attributes such as line
    numbers and column offsets are not dumped by default.  If this is wanted,
    include_attributes can be set to true.
    c	st|t�r�g}�}|jD]V}zt||�}Wntk
rBd}YqX|r`|�d|�|�f�q|��|��q�r�|jr�|jD]:}z |�d|�t||��f�Wq�tk
r�Yq�Xq�d|jjd�	|�fSt|t
�r�dd�	�fdd�|D��St|�S)NTz%s=%sz%s(%s)z, z[%s]c3s|]}�|�VqdSrr)�.0�x)�_formatrr�	<genexpr>�sz(dump.<locals>._format.<locals>.<genexpr>)r
�AST�_fields�getattr�AttributeError�append�_attributes�	__class__�__name__�joinr(�repr)r�args�keywords�fieldr�a�r9�annotate_fields�include_attributesrrr9ps*




 
zdump.<locals>._formatzexpected AST, got %r)r
r;�	TypeErrorrArB)rrJrKrrIr�dumpfs

rMcCsVdD]L}||jkr||jkrt||d�}|dk	sDt||�r|�d�rt|||�q|S)z�
    Copy source location (`lineno`, `col_offset`, `end_lineno`, and `end_col_offset`
    attributes) from *old_node* to *new_node* if possible, and return *new_node*.
    )�lineno�
col_offset�
end_lineno�end_col_offsetNZend_)r@r=�hasattr�
startswith�setattr)�new_nodeZold_node�attrrrrr�
copy_location�s��rWcs �fdd���|dddd�|S)a{
    When you compile a node tree with compile(), the compiler expects lineno and
    col_offset attributes for every node that supports them.  This is rather
    tedious to fill in for generated nodes, so this helper adds these attributes
    recursively where not already set, by setting them to the values of the
    parent node.  It works recursively starting at *node*.
    cs�d|jkr"t|d�s||_n|j}d|jkrDt|d�s>||_n|j}d|jkrft|d�s`||_n|j}d|jkr�t|d�s�||_n|j}t|�D]}�|||||�q�dS)NrNrPrOrQ)r@rRrNrPrOrQ�iter_child_nodes)rrNrOrPrQ�child��_fixrrr[�s$







z#fix_missing_locations.<locals>._fix�rrrrrZr�fix_missing_locations�sr]r\cCsVt|�D]H}d|jkr(t|dd�||_d|jkrt|dd�}dk	r|||_q|S)z�
    Increment the line number and end line number of each node in the tree
    starting at *node* by *n*. This is useful to "move code" to a different
    location in a file.
    rNrrPN)�walkr@r=rNrP)r�nrYrPrrr�increment_lineno�s
��r`c	cs:|jD].}z|t||�fVWqtk
r2YqXqdS)zs
    Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
    that is present on *node*.
    N)r<r=r>)rrGrrr�iter_fields�s

raccsLt|�D]>\}}t|t�r"|Vqt|t�r|D]}t|t�r0|Vq0qdS)z�
    Yield all direct child nodes of *node*, that is, all fields that are nodes
    and all items of fields that are lists of nodes.
    N)rar
r;r()r�namerG�itemrrrrX�s


rXcCs�t|ttttf�s"td|jj��|jr8t|jdt	�s<dS|jdj
}t|t�rZ|j}n"t|t
�rxt|j
t�rx|j
}ndS|r�ddl}|�|�}|S)aC
    Return the docstring for the given node or None if no docstring can
    be found.  If the node provided does not have docstrings a TypeError
    will be raised.

    If *clean* is `True`, all tabs are expanded to spaces and any whitespace
    that can be uniformly removed from the second line onwards is removed.
    z%r can't have docstringsrN)r
ZAsyncFunctionDefZFunctionDefZClassDefZModulerLrArBr5ZExprr�Str�srr4�inspectZcleandoc)rZclean�textrfrrr�
get_docstring�s	

rhcCs�d}g}d}|t|�krx||}||7}|d7}|dkr`|t|�kr`||dkr`|d7}|d7}|dkr|�|�d}q|r�|�|�|S)z}Split a string into lines ignoring form feed and other chars.

    This mimics how the Python parser splits source code.
    r�r\�
�
z
)r+r?)r�idx�linesZ	next_line�crrr�_splitlines_no_ffs  

rocCs,d}|D]}|dkr||7}q|d7}q|S)z6Replace all chars except '\f\t' in a line with spaces.riz	� r)r�resultrnrrr�_pad_whitespaces

rr)�paddedcCs�z$|jd}|jd}|j}|j}Wntk
r:YdSXt|�}||krd||��||���S|r�t||��d|����}nd}|||��|d���}	||��d|���}
||d|�}|�	d|	�|�
|
�d�|�S)aBGet source code segment of the *source* that generated *node*.

    If some location information (`lineno`, `end_lineno`, `col_offset`,
    or `end_col_offset`) is missing, return None.

    If *padded* is `True`, the first line of a multi-line statement will
    be padded with spaces to match its original position.
    r\Nrir)rNrPrOrQr>ro�encode�decoderr�insertr?rC)rrrsrNrPrOrQrmZpadding�firstZlastrrr�get_source_segment*s&	



rxccs<ddlm}||g�}|r8|��}|�t|��|VqdS)z�
    Recursively yield all descendant nodes in the tree starting at *node*
    (including *node* itself), in no specified order.  This is useful if you
    only want to modify nodes in place and don't care about the context.
    r)�dequeN)�collectionsry�popleft�extendrX)rryZtodorrrr^Ms
r^c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�NodeVisitora<
    A node visitor base class that walks the abstract syntax tree and calls a
    visitor function for every node found.  This function may return a value
    which is forwarded by the `visit` method.

    This class is meant to be subclassed, with the subclass adding visitor
    methods.

    Per default the visitor functions for the nodes are ``'visit_'`` +
    class name of the node.  So a `TryFinally` node visit function would
    be `visit_TryFinally`.  This behavior can be changed by overriding
    the `visit` method.  If no visitor function exists for a node
    (return value `None`) the `generic_visit` visitor is used instead.

    Don't use the `NodeVisitor` if you want to apply changes to nodes during
    traversing.  For this a special visitor exists (`NodeTransformer`) that
    allows modifications.
    cCs"d|jj}t|||j�}||�S)z
Visit a node.�visit_)rArBr=�
generic_visit)�selfr�method�visitorrrr�visitoszNodeVisitor.visitcCsTt|�D]F\}}t|t�r:|D]}t|t�r|�|�qqt|t�r|�|�qdS)z9Called if no explicit visitor function exists for a node.N)rar
r(r;r�)r�rrGrrcrrrrus


zNodeVisitor.generic_visitc	Cs�|j}t�t|��}|dkr@t��D]\}}t||�r$|}q@q$|dk	r�d|}zt||�}Wntk
rrYn&Xddl}|�	|�d�t
d�||�S|�|�S)Nr~rz" is deprecated; add visit_Constant�)r�_const_node_type_names�getr�itemsr
r=r>�warnings�warn�PendingDeprecationWarningr)	r�rrZ	type_name�clsrbr�r�r�rrr�visit_Constants(
�zNodeVisitor.visit_ConstantN)rB�
__module__�__qualname__�__doc__r�rr�rrrrr}[s
r}c@seZdZdZdd�ZdS)�NodeTransformeraG
    A :class:`NodeVisitor` subclass that walks the abstract syntax tree and
    allows modification of nodes.

    The `NodeTransformer` will walk the AST and use the return value of the
    visitor methods to replace or remove the old node.  If the return value of
    the visitor method is ``None``, the node will be removed from its location,
    otherwise it is replaced with the return value.  The return value may be the
    original node in which case no replacement takes place.

    Here is an example transformer that rewrites all occurrences of name lookups
    (``foo``) to ``data['foo']``::

       class RewriteName(NodeTransformer):

           def visit_Name(self, node):
               return Subscript(
                   value=Name(id='data', ctx=Load()),
                   slice=Index(value=Str(s=node.id)),
                   ctx=node.ctx
               )

    Keep in mind that if the node you're operating on has child nodes you must
    either transform the child nodes yourself or call the :meth:`generic_visit`
    method for the node first.

    For nodes that were part of a collection of statements (that applies to all
    statement nodes), the visitor may also return a list of nodes rather than
    just a single node.

    Usually you use the transformer like this::

       node = YourTransformer().visit(node)
    cCs�t|�D]�\}}t|t�rvg}|D]D}t|t�r\|�|�}|dkrFq"nt|t�s\|�|�q"|�|�q"||dd�<qt|t�r|�|�}|dkr�t||�qt|||�q|Sr)	rar
r(r;r�r|r?�delattrrT)r�rrG�	old_valueZ
new_valuesrrUrrrr�s&






zNodeTransformer.generic_visitN)rBr�r�r�rrrrrr��s#r�cCs|jSr�r)r�rrr�_getter�sr�cCs
||_dSrr�)r�rrrr�_setter�sr�c@seZdZdd�ZdS)�_ABCcCsft|t�sdS|tkrZz
|j}Wntk
r6YdSXt|t|�oXt|t�|d��St�||�S)NFr)	r
r�_const_typesrr>�_const_types_notr�r�__instancecheck__)r��instrrrrr��s

�z_ABC.__instancecheck__N)rBr�r�r�rrrrr��sr�cOsf|D]<}||jkrq|j�|�}|t|�krt|j�d|����q|tkrTt||�Stj|f|�|�S)Nz" got multiple values for argument )r<�indexr+rLrBr�r�__new__)r�rE�kwargs�key�posrrr�_new�s

r�c@seZdZdZeZdS)�Num)r_N�rBr�r�r<r�r�rrrrr��sr�)�	metaclassc@seZdZdZeZdS)rd�reNr�rrrrrd�srdc@seZdZdZeZdS)�Bytesr�Nr�rrrrr�sr�c@seZdZeZdS)�NameConstantN)rBr�r�r�r�rrrrr�sr�c@seZdZdZdd�ZdS)�EllipsisrcOs(|tkrtd|�|�Stj|f|�|�S)N.).)r�rr�)r�rEr�rrrr�szEllipsis.__new__N)rBr�r�r<r�rrrrr�sr�.)rr)TF)r\)T))r��_astrr6rMrWr]r`rarXrhrorrrxr^�objectr}r�r�r��propertyrr_rerr�r�r�rdr�r�r�r r!r"r4�bytes�boolr�r�r�rrrr�<module>sz�3
'#

#:>	
���