Sindbad~EG File Manager
�
Mٜg�6 � � � d Z ddlmZ ddlZddlmZ ddlZddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZmZ dd
lmZ ddlmZ ddlmZ dd
lmZ erddlmZ dd�Zdd�Zd� Zd� Zdd�Z dd�Z! d dd�Z"y)z
Top level ``eval`` module.
� )�annotationsN)�
TYPE_CHECKING)�find_stack_level)�validate_bool_kwarg��is_extension_array_dtype)�ENGINES)�PARSERS�Expr)�tokenize_string)�ensure_scope)�NDFrame)�pprint_thing)�BinOpc � � ddl m} ddlm} | �|rdnd} | t vr.t t j � � }t d| � d|� �� �| dk( r
|st d� �| S ) a?
Make sure a valid engine is passed.
Parameters
----------
engine : str
String to validate.
Raises
------
KeyError
* If an invalid engine is passed.
ImportError
* If numexpr was requested but doesn't exist.
Returns
-------
str
Engine name.
r )�NUMEXPR_INSTALLED)�USE_NUMEXPR�numexpr�pythonzInvalid engine 'z' passed, valid engines are z~'numexpr' is not installed or an unsupported version. Cannot use engine='numexpr' for query/eval if 'numexpr' is not installed) �pandas.core.computation.checkr �#pandas.core.computation.expressionsr r �list�keys�KeyError�ImportError)�enginer r �
valid_enginess �G/usr/local/lib/python3.12/site-packages/pandas/core/computation/eval.py�
_check_enginer sv � �* @�?�
�~�)��x��
�W���W�\�\�^�,�
���v�h�&B�=�/�R�
�
� ���#4��
L�
�
�
�M� c �Z � | t vr#t d| � dt j � � �� �y)z�
Make sure a valid parser is passed.
Parameters
----------
parser : str
Raises
------
KeyError
* If an invalid parser is passed
zInvalid parser 'z' passed, valid parsers are N)r
r r )�parsers r �
_check_parserr# K s6 � � �W����v�h�&B�7�<�<�>�BR�S�
�
� r c �x � | �8| D ]2 }t |d� r�t |� j }t d|� d�� � y y )N�__getitem__zResolver of type 'z+' does not implement the __getitem__ method)�hasattr�type�__name__� TypeError)� resolvers�resolver�names r �_check_resolversr- ^ sN � ���!�H��8�]�3��H�~�.�.���(��� /7� 7�� � "� r c � � | st d� �y)z�
Make sure an expression is not an empty string
Parameters
----------
expr : object
An object that can be converted to a string
Raises
------
ValueError
* If expr is an empty string
zexpr cannot be an empty stringN)�
ValueError)�exprs r �_check_expressionr1 i s � � ��9�:�:� r c �2 � t | � }t |� |S )a&
Convert an object to an expression.
This function converts an object to an expression (a unicode string) and
checks to make sure it isn't empty after conversion. This is used to
convert operators to their string representation for recursive calls to
:func:`~pandas.eval`.
Parameters
----------
expr : object
The object to be converted to a string.
Returns
-------
str
The string representation of an object.
Raises
------
ValueError
* If the expression is empty.
)r r1 )r0 �ss r �_convert_expressionr4 { s � �0 �T��A��a���Hr c � � |dk( }|dk7 }|rd}n|rd}|s|r8t | � D ]) \ }}|t j k( s�|dk( s� t � � y y )Nr �pandasz5The '@' prefix is only supported by the pandas parserzuThe '@' prefix is not allowed in top-level eval calls.
please refer to your variables by name without the '@' prefix.�@)r �tokenize�OP�SyntaxError)r0 �stack_levelr"