HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/jmespath/__pycache__/functions.cpython-310.pyc
o

�h�1�
@s�ddlZddlZddlmZddlmZddlmZddddd	d	d
d
d
dddd�Zd
ddddddd�Z	dd�Z
Gdd�de�ZGdd�ded�Z
dS)�N)�
exceptions)�string_type)�get_methods�boolean�array�object�null�string�number�expref)�bool�list�dict�NoneType�unicode�str�float�int�long�OrderedDict�_Projection�_Expression)r)r
r)rr)r)rr)rrr)r)rrrrr	r
rcs�fdd�}|S)Ncs
�|_|S�N)�	signature)�func��	arguments��E/usr/local/CyberCP/lib/python3.10/site-packages/jmespath/functions.py�_record_signature'sz$signature.<locals>._record_signaturer)rrrrrr&srcs$eZdZ�fdd�Zdd�Z�ZS)�FunctionRegistrycs |��tt|��|||�dSr)�_populate_function_table�superr �__init__)�cls�name�bases�attrs��	__class__rrr#.szFunctionRegistry.__init__cCsVi}t|�D]\}}|�d�sqt|dd�}|dur%||d�||dd�<q||_dS)N�_func_r)�functionr�)r�
startswith�getattr�FUNCTION_TABLE)r$�function_tabler%�methodrrrrr!2s
��
z)FunctionRegistry._populate_function_table)�__name__�
__module__�__qualname__r#r!�
__classcell__rrr(rr -sr c@s�eZdZiZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	e
d
dgi�dd��Ze
d
dgi�dd��Ze
gdd��dd��Z
e
d
gi�dd��Ze
d
gi�dd��Ze
d
gi�dd��Ze
d
ddgid
gi�d d!��Ze
d
gd"�i�d#d$��Ze
d
dgid
dgi�d%d&��Ze
d
dgid
dgi�d'd(��Ze
d
ddgi�d)d*��Ze
d
dgi�d+d,��Ze
d
dgi�d-d.��Ze
d
dgid
d/gi�d0d1��Ze
d
d2gid
dgi�d3d4��Ze
d
dd/gi�d5d6��Ze
d7gdd��d8d9��Ze
d
dd/gi�d:d;��Ze
d
d/dgi�d<d=��Ze
d
dgi�d>d?��Ze
d
d7gi�d@dA��Ze
d
d7gi�dBdC��Z e
d
gi�dDdE��Z!e
d
dgid
d2gi�dFdG��Z"e
d
dgid
d2gi�dHdI��Z#e
d
dgid
d2gi�dJdK��Z$dLdM�Z%dNdO�Z&dPS)Q�	FunctionscCsZz|j|}Wntyt�d|��w|d}|d}|�|||�||g|�R�S)NzUnknown function: %s()r+r)r/�KeyErrorr�UnknownFunctionError�_validate_arguments)�self�
function_name�
resolved_args�specr+rrrr�
call_functionHs��zFunctions.call_functioncCsn|r|d�d�rt|�t|�krt�t|�t|�|��nt|�t|�kr0t�t|�t|�|��|�|||�S)N����variadic)�get�lenr�VariadictArityError�
ArityError�_type_check)r:�argsrr;rrrr9Ss���zFunctions._validate_argumentscCs8tt|��D]}||d}|r|�||||�qdS)N�types)�rangerB�_type_check_single)r:�actualrr;�i�
allowed_typesrrrrE]s���zFunctions._type_checkcCsR|�|�\}}t|�j}||vrt�|||�|�|��|r'|�||||�dSdSr)�_get_allowed_pytypes�typer2r�JMESPathTypeError�_convert_to_jmespath_type�_subtype_check)r:�currentrGr;rL�allowed_subtypes�actual_typenamerrrrIds

���zFunctions._type_check_singlecCs`g}g}|D]%}|�dd�}t|�dkr |\}}|�t|�n|d}|�t|�q||fS)N�-��r)�splitrB�append�REVERSE_TYPES_MAP�extend)r:rGrLrS�t�type_�subtyperrrrM{szFunctions._get_allowed_pytypesc
Cs�t|�dkr"|d}|D]}t|�j}||vrt�||||��qdSt|�dkr^|r`t|d�j}|D]
}||vr=|}	nq3t�||d||��|D]}t|�j}||	vr]t�||||��qJdSdSdS)NrVr)rBrNr2rrO)
r:rRrSrGr;�elementrT�first�subtypes�allowedrrrrQ�s:
�����
���zFunctions._subtype_checkrGr
cC�t|�Sr)�abs�r:�argrrr�	_func_abs��zFunctions._func_abszarray-numbercCs|rt|�tt|��SdSr)�sumrrBrerrr�	_func_avg�szFunctions._func_avgT)rGr@cGs|D]
}|dur|SqdSrr)r:r�argumentrrr�_func_not_null�s
��zFunctions._func_not_nullcCst|t�r|S|gSr)�
isinstancer
rerrr�_func_to_array�s
zFunctions._func_to_arraycCst|t�r|Stj|dtd�S)N)�,�:)�
separators�default)rm�STRING_TYPE�json�dumpsrrerrr�_func_to_string�s

�zFunctions._func_to_stringcCsrt|tttf�r
dS|durdSt|ttf�r|Szt|�WSty8zt|�WYSty7YYdSwwr)rmr
rrrr�
ValueErrorrerrr�_func_to_number�s
��zFunctions._func_to_numberrr	cCs||vSrr)r:�subject�searchrrr�_func_contains�rhzFunctions._func_contains)r	rrcCrcr)rBrerrr�_func_length�rhzFunctions._func_lengthcC�
|�|�Sr)�endswith�r:rz�suffixrrr�_func_ends_with��
zFunctions._func_ends_withcCr}r)r-rrrr�_func_starts_with�r�zFunctions._func_starts_withcCs$t|t�r|ddd�Stt|��S)Nr?)rmrsr
�reversedrerrr�
_func_reverse�s
zFunctions._func_reversecC�
t�|�Sr)�math�ceilrerrr�
_func_ceil�r�zFunctions._func_ceilcCr�r)r��floorrerrr�_func_floor�r�zFunctions._func_floorzarray-stringcCr}r)�join)r:�	separatorrrrr�
_func_join�r�zFunctions._func_joinrcCs&g}|D]}|�|�|j|��q|Sr)rY�visit�
expression)r:rrf�resultr_rrr�	_func_map�szFunctions._func_mapcC�|rt|�SdSr)�maxrerrr�	_func_max��zFunctions._func_maxrcGsi}|D]}|�|�q|Sr)�update)r:r�mergedrfrrr�_func_mergeszFunctions._func_mergecCr�r)�minrerrr�	_func_min
r�zFunctions._func_mincCstt|��Sr)r
�sortedrerrr�
_func_sort�zFunctions._func_sortcCrcr)rirerrr�	_func_sumrhzFunctions._func_sumcC�t|���Sr)r
�keysrerrr�
_func_keysszFunctions._func_keyscCr�r)r
�valuesrerrr�_func_values"r�zFunctions._func_valuescCsZt|t�rdSt|t�rdSt|t�rdSt|t�rdSt|ttf�r%dS|dur+dSdS)Nr	rrrr
r)rmrsrr
rrrrerrr�
_func_type&s



�zFunctions._func_typecCsf|s|S|�t|�|j|d��j�}|dvr#t�d|d|ddg��|�||gd�}tt	||d��S)Nr)r
r	�sort_byr	r
��key)
rPrNr�r�r2rrO�_create_key_funcr
r�)r:rr�
required_type�keyfuncrrr�
_func_sort_by5s���zFunctions._func_sort_bycC�&|�|ddgd�}|rt||d�SdS)Nr
r	�min_byr�)r�r��r:rrr�rrr�_func_min_byI��zFunctions._func_min_bycCr�)Nr
r	�max_byr�)r�r�r�rrr�_func_max_bySr�zFunctions._func_max_bycs����fdd�}|S)Ncs>���j|�}t|�j}��|�}|�vrt��||���|Sr)r�r�rNr2rPrrO)�xr�rT�
jmespath_type�rLrr;r:rrr�^s

�z+Functions._create_key_func.<locals>.keyfuncr)r:rrLr;r�rr�rr�]s	zFunctions._create_key_funccCst�|d�S)N�unknown)�	TYPES_MAPrA)r:�pyobjectrrrrPisz#Functions._convert_to_jmespath_typeN)'r2r3r4r/r>r9rErIrMrQrrgrjrlrnrvrxr{r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rPrrrrr6Cs|






























	
	r6)�	metaclass)r�rt�jmespathr�jmespath.compatrrsrr�rZrrNr r6rrrr�<module>s:��