| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Python312/Lib/site-packages/pandas/core/computation/__pycache__/ |
Upload File : |
�
- �g� � � � d Z ddlmZ ddlmZ ddlmZ ddlZddlZddl m
Z
e
rddlmZm
Z
dZdd �Zdd
�Zdd�Z dd�Zdd
�Zy)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 ��ci c] \ }}|dt
j | � d��� }}}|j ddddddddd �� d
j | D �cg c] }|j ||� �� c}� } d| � �} | j � st 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_zCould 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 �AC:\Python312\Lib\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'��( Vs �"C�
Cc �\ � | \ }}|t k( rt j t |� fS ||fS )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 | cY S w xY 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&