Ë
    ¤ehÿ  ã                  ó˜   — d Z ddlmZ ddlmZ ddlmZ ddlZddlZddl	m
Z
 e
rddlmZmZ dZdd	„Zdd
„Zdd„Z	 	 	 	 	 	 	 	 dd„Zdd„Zy)z6
:func:`~pandas.eval` source string parsing functions
é    )Úannotations)ÚStringIO)Ú	iskeywordN)ÚTYPE_CHECKING)ÚHashableÚIteratoréd   c                ó¼  — | j                  «       rt        | «      s| S t        j                  j	                  «       D ��ci c]  \  }}|dt
        j                  |   › d�“Œ }}}|j                  ddddddddd	œ«       d
j                  | D �cg c]  }|j                  ||«      ‘Œ c}«      } d| › �} | j                  «       st        d| › d�«      ‚| S c c}}w c c}w )a=  
    Create valid Python identifiers from any string.

    Check if name contains any special characters. If it contains any
    special characters, the special characters will be replaced by
    a special string and a prefix is added.

    Raises
    ------
    SyntaxError
        If the returned name is not a Python valid identifier, raise an exception.
        This can happen if there is a hashtag in the name, as the tokenizer will
        than terminate and not find the backtick.
        But also for characters that fall out of the range of (U+0001..U+007F).
    Ú_Ú_QUESTIONMARK_Ú_EXCLAMATIONMARK_Ú_DOLLARSIGN_Ú
_EUROSIGN_Ú_DEGREESIGN_Ú_SINGLEQUOTE_Ú_DOUBLEQUOTE_)ú ú?ú!ú$u   â‚¬õ   Â°ú'ú"Ú ÚBACKTICK_QUOTED_STRING_zCould not convert 'z' to a valid Python identifier.)Úisidentifierr   ÚtokenizeÚEXACT_TOKEN_TYPESÚitemsÚtokenÚtok_nameÚupdateÚjoinÚgetÚSyntaxError)ÚnameÚcharÚtokvalÚspecial_characters_replacementss       ú]/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pandas/core/computation/parsing.pyÚcreate_valid_python_identifierr+      sû   € ð  ×ÑÔ¤9¨T¤?Øˆô &×7Ñ7×=Ñ=Ó?÷'áˆD�&ð 	�”%—.‘. Ñ(Ð)¨Ð+Ñ+ð'Ð#ñ 'ð $×*Ñ*àØ!Ø$ØØØ à Ø ñ	
ôð  �7‰7ÐPTÖUÈÐ3×7Ñ7¸¸dÕCÒUÓV€DØ$ T FÐ+€Dà×ÑÔÜÐ/°¨vÐ5TÐUÓVÐVà€Kùó5'ùò( Vs   ¿"CÂCc                ó\   — | \  }}|t         k(  rt        j                  t        |«      fS ||fS )a[  
    Clean up a column name if surrounded by backticks.

    Backtick quoted string are indicated by a certain tokval value. If a string
    is a backtick quoted token it will processed by
    :func:`_create_valid_python_identifier` so that the parser can find this
    string when the query is executed.
    In this case the tok will get the NAME tokval.

    Parameters
    ----------
    tok : tuple of int, str
        ints correspond to the all caps constants in the tokenize module

    Returns
    -------
    tok : Tuple[int, str]
        Either the input or token or the replacement values
    )ÚBACKTICK_QUOTED_STRINGr   ÚNAMEr+   )ÚtokÚtoknumr(   s      r*   Úclean_backtick_quoted_toksr1   I   s5   € ð( �N€FˆFØÔ'Ò'Ü�}‰}Ô<¸VÓDÐDÐDØ�6ˆ>Ðó    c                óv   — 	 t        d| › d�«      }t        |«      d   }t        |«      S # t        $ r | cY S w xY w)a¼  
    Function to emulate the cleaning of a backtick quoted name.

    The purpose for this function is to see what happens to the name of
    identifier if it goes to the process of being parsed a Python code
    inside a backtick quoted string and than being cleaned
    (removed of any special characters).

    Parameters
    ----------
    name : hashable
        Name to be cleaned.

    Returns
    -------
    name : hashable
        Returns the name after tokenizing and cleaning.

    Notes
    -----
        For some cases, a name cannot be converted to a valid Python identifier.
        In that case :func:`tokenize_string` raises a SyntaxError.
        In that case, we just return the name unmodified.

        If this name was used in the query string (this makes the query call impossible)
        an error will be raised by :func:`tokenize_backtick_quoted_string` instead,
        which is not caught and propagates to the user level.
    ú`é   )Útokenize_stringÚnextr+   r%   )r&   Ú	tokenizedr(   s      r*   Úclean_column_namer9   c   sF   € ð:Ü# a¨ v¨Q KÓ0ˆ	Ü�i“ Ñ#ˆÜ-¨fÓ5Ð5øÜò ØŠðús   ‚'* ª8·8c                óJ   — | D ]  \  }}}}}|dk(  sŒ|d   } n t         || fS )a»  
    Creates a token from a backtick quoted string.

    Moves the token_generator forwards till right after the next backtick.

    Parameters
    ----------
    token_generator : Iterator[tokenize.TokenInfo]
        The generator that yields the tokens of the source string (Tuple[int, str]).
        The generator is at the first token after the backtick (`)

    source : str
        The Python source code string.

    string_start : int
        This is the start of backtick quoted string inside the source string.

    Returns
    -------
    tok: Tuple[int, str]
        The token that represents the backtick quoted string.
        The integer is equal to BACKTICK_QUOTED_STRING (100).
    r4   r5   )r-   )Útoken_generatorÚsourceÚstring_startr   r(   ÚstartÚ
string_ends          r*   Útokenize_backtick_quoted_stringr@   ˆ   sE   € ð4 #2ò Ñˆˆ6�5˜!˜QØ�S‹=Ø˜q™ˆJÙðô
 " 6¨,°zÐ#BÐBÐBr2   c              #  ó  K  — t        | «      j                  }t        j                  |«      }|D ]+  \  }}}}}|dk(  r	 t	        || |d   dz   ¬«      –— Œ&||f–— Œ- y# t
        $ r}t        d| › d�«      |‚d}~ww xY w­w)a$  
    Tokenize a Python source code string.

    Parameters
    ----------
    source : str
        The Python source code string.

    Returns
    -------
    tok_generator : Iterator[Tuple[int, str]]
        An iterator yielding all tokens with only toknum and tokval (Tuple[ing, str]).
    r4   r5   )r=   zFailed to parse backticks in 'z'.N)r   Úreadliner   Úgenerate_tokensr@   Ú	Exceptionr%   )r<   Úline_readerr;   r0   r(   r>   r   Úerrs           r*   r6   r6   ª   s¤   è ø€ ô ˜6Ó"×+Ñ+€KÜ×.Ñ.¨{Ó;€Oð (7ò 	!Ñ#ˆ�˜˜q !Ø�SŠ=ðXÜ5Ø# V¸%À¹(ÀQ¹,ôó ð ˜&�.Ó ñ	!øô ò XÜ!Ð$BÀ6À(È"Ð"MÓNÐTWÐWûðXüs(   ‚;A?¾AÁ
A?Á	A<Á'A7Á7A<Á<A?)r&   ÚstrÚreturnrG   )r/   útuple[int, str]rH   rI   )r&   r   rH   r   )r;   zIterator[tokenize.TokenInfo]r<   rG   r=   ÚintrH   rI   )r<   rG   rH   zIterator[tuple[int, str]])Ú__doc__Ú
__future__r   Úior   Úkeywordr   r    r   Útypingr   Úcollections.abcr   r   r-   r+   r1   r9   r@   r6   © r2   r*   ú<module>rR      so   ðñõ #å Ý Û Û Ý  á÷ð Ð ó0ófó4"ðJCØ1ðCØ;>ðCØNQðCàóCôD!r2   