o
    DDi                     @   s   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ er0d dlmZ ed ZG d	d
 d
e
eZG dd deeZdS )    )TYPE_CHECKINGUnion)FlattenSentinel)MetadataDependent)RemovalSentinel)CSTTypedTransformerFunctionsCSTTypedVisitorFunctions)CSTNodeT)CSTNode)CSTTransformer
CSTVisitorc                
   @   sr   e Zd ZdZdddefddZdededeeee	e f fd	d
Z
dddeddfddZdddeddfddZdS )r   aB  
    The low-level base visitor class for traversing a CST and creating an
    updated copy of the original CST. This should be used in conjunction with
    the :func:`~libcst.CSTNode.visit` method on a :class:`~libcst.CSTNode` to
    visit each element in a tree starting with that node, and possibly returning
    a new node in its place.

    When visiting nodes using a :class:`CSTTransformer`, the return value of
    :func:`~libcst.CSTNode.visit` will be a new tree with any changes made in
    :func:`~libcst.CSTTransformer.on_leave` calls reflected in its children.
    noder
   returnc                 C   >   t | dt|j d}|dur||}nd}|du rdS dS z
        Called every time a node is visited, before we've visited its children.

        Returns ``True`` if children should be visited, and returns ``False``
        otherwise.
        visit_NTFgetattrtype__name__selfr   
visit_funcretval r   I/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/_visitors.pyon_visit#   
   
zCSTTransformer.on_visitoriginal_nodeupdated_nodec                 C   s.   t | dt|j d}|dur|||}|S )a{  
        Called every time we leave a node, after we've visited its children. If
        the :func:`~libcst.CSTTransformer.on_visit` function for this node returns
        ``False``, this function will still be called on that node.

        ``original_node`` is guaranteed to be the same node as is passed to
        :func:`~libcst.CSTTransformer.on_visit`, so it is safe to do state-based
        checks using the ``is`` operator. Modifications should always be performed
        on the ``updated_node`` so as to not overwrite changes made by child
        visits.

        Returning :attr:`RemovalSentinel.REMOVE` indicates that the node should be
        removed from its parent. This is not always possible, and may raise an
        exception if this node is required. As a convenience, you can use
        :func:`RemoveFromParent` as an alias to :attr:`RemovalSentinel.REMOVE`.
        leave_Nr   )r   r   r   
leave_funcr   r   r   on_leave2   s   
zCSTTransformer.on_leave	attributeNc                 C   6   t | dt|j d| d}|dur|| dS dS a  
        Called before a node's child attribute is visited and after we have called
        :func:`~libcst.CSTTransformer.on_visit` on the node. A node's child
        attributes are visited in the order that they appear in source that this
        node originates from.
        r   _Nr   r   r   r#   r   r   r   r   on_visit_attributeK      z!CSTTransformer.on_visit_attributec                 C   r$   )aF  
        Called after a node's child attribute is visited and before we have called
        :func:`~libcst.CSTTransformer.on_leave` on the node.

        Unlike :func:`~libcst.CSTTransformer.on_leave`, this function does
        not allow modifications to the tree and is provided solely for state
        management.
        r    r&   Nr   r   r   r#   r!   r   r   r   on_leave_attributeV   s   	z!CSTTransformer.on_leave_attribute)r   
__module____qualname____doc__boolr   r	   r   r   r   r"   strr(   r+   r   r   r   r   r      s    
r   c                   @   sX   e Zd ZdZdddefddZdd	d
ZdddeddfddZdddeddfddZ	dS )r   a  
    The low-level base visitor class for traversing a CST. This should be used in
    conjunction with the :func:`~libcst.CSTNode.visit` method on a
    :class:`~libcst.CSTNode` to visit each element in a tree starting with that
    node. Unlike :class:`CSTTransformer`, instances of this class cannot modify
    the tree.

    When visiting nodes using a :class:`CSTVisitor`, the return value of
    :func:`~libcst.CSTNode.visit` will equal the passed in tree.
    r   r
   r   c                 C   r   r   r   r   r   r   r   r   r   r   zCSTVisitor.on_visitr   Nc                 C   s0   t | dt|j d}|dur|| dS dS )z
        Called every time we leave a node, after we've visited its children. If
        the :func:`~libcst.CSTVisitor.on_visit` function for this node returns
        ``False``, this function will still be called on that node.
        r    Nr   )r   r   r!   r   r   r   r"      s   zCSTVisitor.on_leaver#   c                 C   r$   r%   r   r'   r   r   r   r(      r)   zCSTVisitor.on_visit_attributec                 C   r$   )z
        Called after a node's child attribute is visited and before we have called
        :func:`~libcst.CSTVisitor.on_leave` on the node.
        r    r&   Nr   r*   r   r   r   r+      s   zCSTVisitor.on_leave_attribute)r   r
   r   N)
r   r,   r-   r.   r/   r   r"   r0   r(   r+   r   r   r   r   r   f   s    

r   N)typingr   r   libcst._flatten_sentinelr   libcst._metadata_dependentr   libcst._removal_sentinelr   libcst._typed_visitorr   r   libcst._typesr	   libcst._nodes.baser
   CSTVisitorTr   r   r   r   r   r   <module>   s   P