§
    Ð! 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dS )z6
:func:`~pandas.eval` source string parsing functions
é    )Úannotations)ÚStringIO)Ú	iskeywordN)ÚTYPE_CHECKING)ÚHashableÚIteratoréd   ÚnameÚstrÚreturnc                óx  ‡— |                       ¦   «         rt          | ¦  «        s| S d„ t          j                             ¦   «         D ¦   «         Š‰                     dddddddd	d
œ¦  «         d                     ˆfd„| D ¦   «         ¦  «        } d| › �} |                       ¦   «         st          d| › d�¦  «        ‚| S )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).
    c                óB   — i | ]\  }}|d t           j        |         › d �“ŒS )Ú_)ÚtokenÚtok_name)Ú.0ÚcharÚtokvals      úYc:\xampp_lite_8_4\www\timesheet\venv\Lib\site-packages\pandas/core/computation/parsing.pyú
<dictcomp>z2create_valid_python_identifier.<locals>.<dictcomp>,   sA   € ð 'ð 'ð 'áˆD�&ð 	Ð+•%”. Ô(Ð+Ð+Ð+ð'ð 'ð 'ó    r   Ú_QUESTIONMARK_Ú_EXCLAMATIONMARK_Ú_DOLLARSIGN_Ú
_EUROSIGN_Ú_DEGREESIGN_Ú_SINGLEQUOTE_Ú_DOUBLEQUOTE_)ú ú?ú!ú$u   â‚¬õ   Â°ú'ú"Ú c                ó<   •— g | ]}‰                      ||¦  «        ‘ŒS © )Úget)r   r   Úspecial_characters_replacementss     €r   ú
<listcomp>z2create_valid_python_identifier.<locals>.<listcomp>@   s*   ø€ ÐUÐUÐUÈÐ3×7Ò7¸¸dÑCÔCÐUÐUÐUr   ÚBACKTICK_QUOTED_STRING_zCould not convert 'z' to a valid Python identifier.)Úisidentifierr   ÚtokenizeÚEXACT_TOKEN_TYPESÚitemsÚupdateÚjoinÚSyntaxError)r
   r*   s    @r   Úcreate_valid_python_identifierr4      sÿ   ø€ ð  ×ÒÑÔð ¥9¨T¡?¤?ð Øˆð
'ð 'å%Ô7×=Ò=Ñ?Ô?ð'ñ 'ô 'Ð#ð $×*Ò*àØ!Ø$ØØØ à Ø ð	
ð 	
ñô ð ð  �7Š7ÐUÐUÐUÐUÐPTÐUÑUÔUÑVÔV€DØ+ TÐ+Ð+€Dà×ÒÑÔð WÝÐU°ÐUÐUÐUÑVÔVÐVà€Kr   Útokútuple[int, str]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.   ÚNAMEr4   )r5   Útoknumr   s      r   Úclean_backtick_quoted_toksr;   I   s9   € ð( �N€FˆFØÕ'Ò'Ð'ÝŒ}Õ<¸VÑDÔDÐDÐDØ�6ˆ>Ðr   r   c                ó–   — 	 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Únextr4   r3   )r
   Ú	tokenizedr   s      r   Úclean_column_namerB   c   s^   € ð:Ý# K¨ K K KÑ0Ô0ˆ	Ý�i‘” Ô#ˆÝ-¨fÑ5Ô5Ð5øÝð ð ð Øˆˆˆðøøøs   ‚69 ¹AÁAÚtoken_generatorúIterator[tokenize.TokenInfo]ÚsourceÚstring_startÚintc                óZ   — | D ]\  }}}}}|dk    r
|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).
    r=   r>   )r8   )rC   rE   rF   r   r   ÚstartÚ
string_ends          r   Útokenize_backtick_quoted_stringrK   ˆ   sQ   € ð4 #2ð ð Ñˆˆ6�5˜!˜QØ�SŠ=ˆ=Ø˜qœˆJØˆEð õ " 6¨,°zÐ*AÔ#BÐBÐBr   úIterator[tuple[int, str]]c              #  ó  K  — t          | ¦  «        j        }t          j        |¦  «        }|D ]Y\  }}}}}|dk    rE	 t	          || |d         dz   ¬¦  «        V — Œ-# t
          $ r}t          d| › d�¦  «        |‚d}~ww xY w||fV — ŒZdS )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]).
    r=   r>   )rF   zFailed to parse backticks in 'z'.N)r   Úreadliner.   Úgenerate_tokensrK   Ú	Exceptionr3   )rE   Úline_readerrC   r:   r   rI   r   Úerrs           r   r?   r?   ª   sé   è è € õ ˜6Ñ"Ô"Ô+€KÝÔ.¨{Ñ;Ô;€Oð (7ð 	!ð 	!Ñ#ˆ�˜˜q !Ø�SŠ=ˆ=ðXÝ5Ø# V¸%À¼(ÀQ¹,ðñ ô ð ð ð ð øõ ð Xð Xð XÝ!Ð"MÀ6Ð"MÐ"MÐ"MÑNÔNÐTWÐWøøøøðXøøøð ˜&�.Ð Ð Ð Ð ð	!ð 	!s   ¼AÁ
A=Á$A8Á8A=)r
   r   r   r   )r5   r6   r   r6   )r
   r   r   r   )rC   rD   rE   r   rF   rG   r   r6   )rE   r   r   rL   )Ú__doc__Ú
__future__r   Úior   Úkeywordr   r   r.   Útypingr   Úcollections.abcr   r   r8   r4   r;   rB   rK   r?   r(   r   r   ú<module>rY      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø €€€Ø €€€Ø  Ð  Ð  Ð  Ð  Ð  àð ðð ð ð ð ð ð ð ð Ð ð0ð 0ð 0ð 0ðfð ð ð ð4"ð "ð "ð "ðJCð Cð Cð CðD!ð !ð !ð !ð !ð !r   