o
    iZ                     @  s   d dl mZ d dlmZ d dlmZ d dlmZ er d dlm	Z	 dd
dZ
dddZdddZdddZdddZd ddZd ddZd ddZd ddZdS )!    )annotations)AST)TYPE_CHECKING)LastNodeError)Iteratornoder   returnstrc                 C  s   | j j S )zvReturn the kind of an AST node.

    Parameters:
        node: The AST node.

    Returns:
        The node kind.
    )	__class____name__lowerr    r   g/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/griffe/_internal/agents/nodes/ast.pyast_kind   s   	r   Iterator[AST]c              	   c  sv    | j D ]4}zt| |}W n	 ty   Y qw t|tr#| |_|V  qt|tr8|D ]}t|tr7| |_|V  q*qdS )z}Return the children of an AST node.

    Parameters:
        node: The AST node.

    Yields:
        The node children.
    N)_fieldsgetattrAttributeError
isinstancer   parentlist)r   
field_namefieldchildr   r   r   ast_children   s"   
	


r   c                 c  s*    t | jD ]}|| ur|V  q dS dS )zReturn the previous siblings of this node, starting from the closest.

    Parameters:
        node: The AST node.

    Yields:
        The previous siblings.
    Nr   r   )r   siblingr   r   r   ast_previous_siblings2   s   	r   c                 c  s0    t | j}|D ]}|| u r nq|E dH  dS )zReturn the next siblings of this node, starting from the closest.

    Parameters:
        node: The AST node.

    Yields:
        The next siblings.
    Nr   r   siblingsr   r   r   r   ast_next_siblingsB   s   
	r!   c                 c  s4    t | j}|D ]
}|| ur|V  q |E dH  dS )zvReturn the siblings of this node.

    Parameters:
        node: The AST node.

    Yields:
        The siblings.
    Nr   r   r   r   r   ast_siblingsR   s   
	r"   c                 C  s.   z
t | ^ }}W |S  ty   tddw )zReturn the previous sibling of this node.

    Parameters:
        node: The AST node.

    Raises:
        LastNodeError: When the node does not have previous siblings.

    Returns:
        The sibling.
    zthere is no previous nodeN)r   
ValueErrorr   )r   _lastr   r   r   ast_previousd   s   
r&   c                 C  s(   zt t| W S  ty   tddw )zReturn the next sibling of this node.

    Parameters:
        node: The AST node.

    Raises:
        LastNodeError: When the node does not have next siblings.

    Returns:
        The sibling.
    zthere is no next nodeN)nextr!   StopIterationr   r   r   r   r   ast_nextw   s
   
r)   c              
   C  s2   zt t| W S  ty } ztd|d}~ww )zReturn the first child of this node.

    Parameters:
        node: The AST node.

    Raises:
        LastNodeError: When the node does not have children.

    Returns:
        The child.
    there are no children nodeN)r'   r   r(   r   )r   errorr   r   r   ast_first_child   s   
r,   c              
   C  s8   z
t | ^ }}W |S  ty } ztd|d}~ww )zReturn the lasts child of this node.

    Parameters:
        node: The AST node.

    Raises:
        LastNodeError: When the node does not have children.

    Returns:
        The child.
    r*   N)r   r#   r   )r   r$   r%   r+   r   r   r   ast_last_child   s   
r-   N)r   r   r   r	   )r   r   r   r   )r   r   r   r   )
__future__r   astr   typingr   griffe._internal.exceptionsr   collections.abcr   r   r   r   r!   r"   r&   r)   r,   r-   r   r   r   r   <module>   s   







