o
    DDi+                     @   s  U d dl Z d dlmZmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZmZmZmZ d dlmZmZmZmZ d dlmZ e d	e jZee ed
< e de jZee ed< e de jZee ed< G dd deeZeeddG dd deeZ eeddG dd deZ!eeddG dd deZ"eeddG dd deZ#eeddG dd deZ$eeddG dd deZ%dS )    N)ABCabstractmethod)	dataclass)OptionalPatternSequence)	add_slots)BaseLeafBaseValueTokenCSTNodeCSTValidationError)CodegenStatevisit_optionalvisit_requiredvisit_sequence)CSTVisitorTz([ \f\t]|\\(\r\n?|\n))*SIMPLE_WHITESPACE_REz\r\n?|\n
NEWLINE_REz	#[^\r\n]*
COMMENT_REc                   @   s*   e Zd ZdZdZeedefddZdS )BaseParenthesizableWhitespacea  
    This is the kind of whitespace you might see inside the body of a statement or
    expression between two tokens. This is the most common type of whitespace.

    The list of allowed characters in a whitespace depends on whether it is found
    inside a parenthesized expression or not. This class allows nodes which can be
    found inside or outside a ``()``, ``[]`` or ``{}`` section to accept either
    whitespace form.

    https://docs.python.org/3/reference/lexical_analysis.html#implicit-line-joining

    Parenthesizable whitespace may contain a backslash character (``\``), when used as
    a line-continuation character. While the continuation character isn't technically
    "whitespace", it serves the same purpose.

    Parenthesizable whitespace is often non-semantic (optional), but in cases where
    whitespace solves a grammar ambiguity between tokens (e.g. ``if test``, versus
    ``iftest``), it has some semantic value.
     returnc                 C      dS )Q
        Indicates that this node is empty (zero whitespace characters).
        Nr   selfr   r   Q/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/_nodes/whitespace.pyempty8   s   z#BaseParenthesizableWhitespace.emptyN)	__name__
__module____qualname____doc__	__slots__propertyr   boolr   r   r   r   r   r      s    r   T)frozenc                   @   s6   e Zd ZU dZeed< d	ddZedefddZ	dS )
SimpleWhitespaceaM  
    This is the kind of whitespace you might see inside the body of a statement or
    expression between two tokens. This is the most common type of whitespace.

    A simple whitespace cannot contain a newline character unless it is directly
    preceeded by a line continuation character (``\``). It can contain zero or
    more spaces or tabs. If you need a newline character without a line continuation
    character, use :class:`ParenthesizedWhitespace` instead.

    Simple whitespace is often non-semantic (optional), but in cases where whitespace
    solves a grammar ambiguity between tokens (e.g. ``if test``, versus ``iftest``),
    it has some semantic value.

    An example :class:`SimpleWhitespace` containing a space, a line continuation,
    a newline and another space is as follows::

        SimpleWhitespace(r" \\n ")
    valuer   Nc                 C   (   t | jd u rtdt| j d S )Nz.Got non-whitespace value for whitespace node: )r   	fullmatchr'   r   reprr   r   r   r   	_validate\   
   zSimpleWhitespace._validatec                 C   s   t | jdkS )r   r   )lenr'   r   r   r   r   r   b   s   zSimpleWhitespace.emptyr   N)
r   r   r    r!   str__annotations__r+   r#   r$   r   r   r   r   r   r&   A   s   
 
r&   c                   @   s>   e Zd ZU dZdZee ed< d
ddZde	ddfdd	Z
dS )NewlineaA  
    Represents the newline that ends an :class:`EmptyLine` or a statement (as part of
    :class:`TrailingWhitespace`).

    Other newlines may occur in the document after continuation characters (the
    backslash, ``\``), but those newlines are treated as part of the
    :class:`SimpleWhitespace`.

    Optionally, a value can be specified in order to overwrite the module's default
    newline. In general, this should be left as the default, which is ``None``. This
    is allowed because python modules are permitted to mix multiple unambiguous
    newline markers.
    Nr'   r   c                 C   s2   | j }|rt|d u rtdt| d S d S )Nz'Got an invalid value for newline node: )r'   r   r)   r   r*   )r   r'   r   r   r   r+      s   zNewline._validatestatec                 C   s(   | j }||d u r|j d S | d S N)r'   	add_tokendefault_newline)r   r2   r'   r   r   r   _codegen_impl   s   "zNewline._codegen_implr.   )r   r   r    r!   r'   r   r/   r0   r+   r   r6   r   r   r   r   r1   k   s
   
 
r1   c                   @   s$   e Zd ZU dZeed< dddZdS )Commenta  
    A comment including the leading pound (``#``) character.

    The leading pound character is included in the 'value' property (instead of being
    stripped) to help re-enforce the idea that whitespace immediately after the pound
    character may be significant. E.g::

        # comment with whitespace at the start (usually preferred)
        #comment without whitespace at the start (usually not desirable)

    Usually wrapped in a :class:`TrailingWhitespace` or :class:`EmptyLine` node.
    r'   r   Nc                 C   r(   )Nz(Got non-comment value for comment node: )r   r)   r'   r   r*   r   r   r   r   r+      r,   zComment._validater.   )r   r   r    r!   r/   r0   r+   r   r   r   r   r7      s   
 r7   c                   @   sh   e Zd ZU dZedZeed< dZe	e
 ed< e Zeed< dedd fd	d
ZdeddfddZdS )TrailingWhitespacez
    The whitespace at the end of a line after a statement. If a line contains only
    whitespace, :class:`EmptyLine` should be used instead.
     
whitespaceNcommentnewlinevisitorr   c                 C   s2   t t| d| j|t| d| j|t| d| j|dS )Nr:   r;   r<   )r:   r;   r<   )r8   r   r:   r   r;   r<   r   r=   r   r   r   _visit_and_replace_children   s
   z.TrailingWhitespace._visit_and_replace_childrenr2   c                 C   s4   | j | | j}|d ur|| | j| d S r3   )r:   _codegenr;   r<   r   r2   r;   r   r   r   r6      s
   
z TrailingWhitespace._codegen_impl)r   r   r    r!   r&   fieldr:   r0   r;   r   r7   r1   r<   r   r?   r   r6   r   r   r   r   r8      s   
 r8   c                   @   st   e Zd ZU dZdZeed< edZ	eed< dZ
ee ed< e Zeed< d	ed
d fddZded
dfddZdS )	EmptyLinez
    Represents a line with only whitespace/comments. Usually statements will own any
    :class:`EmptyLine` nodes above themselves, and a :class:`Module` will own the
    document's header/footer :class:`EmptyLine` nodes.
    Tindentr9   r:   Nr;   r<   r=   r   c              	   C   s6   t | jt| d| j|t| d| j|t| d| j|dS )Nr:   r;   r<   )rD   r:   r;   r<   )rC   rD   r   r:   r   r;   r<   r>   r   r   r   r?      s   z%EmptyLine._visit_and_replace_childrenr2   c                 C   sB   | j r|  | j| | j}|d ur|| | j| d S r3   )rD   add_indent_tokensr:   r@   r;   r<   rA   r   r   r   r6      s   
zEmptyLine._codegen_impl)r   r   r    r!   rD   r$   r0   r&   rB   r:   r;   r   r7   r1   r<   r   r?   r   r6   r   r   r   r   rC      s   
 	rC   c                   @   s   e Zd ZU dZe Zeed< dZe	e
 ed< dZeed< edZeed< d	ed
d fddZded
dfddZed
efddZdS )ParenthesizedWhitespacea  
    This is the kind of whitespace you might see inside a parenthesized expression
    or statement between two tokens when there is a newline without a line
    continuation (``\``) character.

    https://docs.python.org/3/reference/lexical_analysis.html#implicit-line-joining

    A parenthesized whitespace cannot be empty since it requires at least one
    :class:`TrailingWhitespace`. If you have whitespace that does not contain
    comments or newlines, use :class:`SimpleWhitespace` instead.
    
first_liner   empty_linesFrD   r9   	last_liner=   r   c              	   C   s6   t t| d| j|t| d| j|| jt| d| j|dS )NrG   rH   rI   )rG   rH   rD   rI   )rF   r   rG   r   rH   rD   rI   r>   r   r   r   r?     s   z3ParenthesizedWhitespace._visit_and_replace_childrenr2   Nc                 C   s@   | j | | jD ]}|| q	| jr|  | j| d S r3   )rG   r@   rH   rD   rE   rI   )r   r2   liner   r   r   r6     s   
z%ParenthesizedWhitespace._codegen_implc                 C   r   )z
        Indicates that this node is empty (zero whitespace characters). For
        :class:`ParenthesizedWhitespace` this will always be ``False``.
        Fr   r   r   r   r   r     s   	zParenthesizedWhitespace.empty)r   r   r    r!   r8   rB   rG   r0   rH   r   rC   rD   r$   r&   rI   r   r?   r   r6   r#   r   r   r   r   r   rF      s   
 

rF   )&reabcr   r   dataclassesr   typingr   r   r   libcst._add_slotsr   libcst._nodes.baser	   r
   r   r   libcst._nodes.internalr   r   r   r   libcst._visitorsr   compileUNICODEr   r/   r0   r   r   r   r&   r1   r7   r8   rC   rF   r   r   r   r   <module>   s<   
#( '