HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/jmespath/__pycache__/functions.cpython-310.pyc
o

;j�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��F/opt/saltstack/salt/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)NZ_func_r)�functionr�)r�
startswith�getattr�FUNCTION_TABLE)r$Zfunction_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.�KeyErrorrZUnknownFunctionError�_validate_arguments)�self�
function_nameZ
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�lenrZVariadictArityErrorZ
ArityError�_type_check)r7�argsrr8rrrr6Ss���zFunctions._validate_argumentscCs8tt|��D]}||d}|r|�||||�qdS)N�types)�ranger>�_type_check_single)r7�actualrr8�i�
allowed_typesrrrr?]s���zFunctions._type_checkcCsR|�|�\}}t|�j}||vrt�|||�|�|��|r'|�||||�dSdSr)�_get_allowed_pytypes�typer0r�JMESPathTypeError�_convert_to_jmespath_type�_subtype_check)r7�currentrAr8rF�allowed_subtypes�actual_typenamerrrrCds

���zFunctions._type_check_singlecCs`g}g}|D]%}|�dd�}t|�dkr |\}}|�t|�n|d}|�t|�q||fS)N�-��r)�splitr>�append�REVERSE_TYPES_MAP�extend)r7rArFrM�t�type_�subtyperrrrG{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)NrPr)r>rHr0rrI)
r7rLrMrAr8�elementrN�firstZsubtypes�allowedrrrrK�s:
�����
���zFunctions._subtype_checkrAr
cC�t|�Sr)�abs�r7�argrrr�	_func_abs��zFunctions._func_abszarray-numbercCs|r
t|�t|�SdSr)�sumr>r^rrr�	_func_avg�szFunctions._func_avgT)rAr<cGs|D]
}|dur|SqdSrr)r7r�argumentrrr�_func_not_null�s
��zFunctions._func_not_nullcCst|t�r|S|gSr)�
isinstancer
r^rrr�_func_to_array�s
zFunctions._func_to_arraycCst|t�r|Stj|dtd�S)N)�,�:)�
separators�default)rf�STRING_TYPE�json�dumpsrr^rrr�_func_to_string�s

�zFunctions._func_to_stringcCsrt|tttf�r
dS|durdSt|ttf�r|Szt|�WSty8zt|�WYSty7YYdSwwr)rfr
rrrr�
ValueErrorr^rrr�_func_to_number�s
��zFunctions._func_to_numberrr	cCs||vSrr)r7�subject�searchrrr�_func_contains�razFunctions._func_contains)r	rrcCr\r)r>r^rrr�_func_length�razFunctions._func_lengthcC�
|�|�Sr)�endswith�r7rs�suffixrrr�_func_ends_with��
zFunctions._func_ends_withcCrvr)r,rxrrr�_func_starts_with�r{zFunctions._func_starts_withcCs$t|t�r|ddd�Stt|��S)Nr;)rfrlr
�reversedr^rrr�
_func_reverse�s
zFunctions._func_reversecC�
t�|�Sr)�math�ceilr^rrr�
_func_ceil�r{zFunctions._func_ceilcCrr)r��floorr^rrr�_func_floor�r{zFunctions._func_floorzarray-stringcCrvr)�join)r7�	separatorrrrr�
_func_join�r{zFunctions._func_joinrcCs&g}|D]}|�|�|j|��q|Sr)rS�visit�
expression)r7rr_�resultrYrrr�	_func_map�szFunctions._func_mapcC�|rt|�SdSr)�maxr^rrr�	_func_max��zFunctions._func_maxrcGsi}|D]}|�|�q|Sr)�update)r7rZmergedr_rrr�_func_mergeszFunctions._func_mergecCr�r)�minr^rrr�	_func_min
r�zFunctions._func_mincCstt|��Sr)r
�sortedr^rrr�
_func_sort�zFunctions._func_sortcCr\r)rbr^rrr�	_func_sumrazFunctions._func_sumcC�t|���Sr)r
�keysr^rrr�
_func_keysszFunctions._func_keyscCr�r)r
�valuesr^rrr�_func_values"r�zFunctions._func_valuescCsZt|t�rdSt|t�rdSt|t�rdSt|t�rdSt|ttf�r%dS|dur+dSdS)Nr	rrrr
r)rfrlrr
rrrr^rrr�
_func_type&s



�zFunctions._func_typecCsf|s|S|�t|�|j|d��j�}|dvr#t�d|d|ddg��|�||gd�}tt	||d��S)Nr)r
r	Zsort_byr	r
��key)
rJrHr�r�r0rrI�_create_key_funcr
r�)r7rrZ
required_type�keyfuncrrr�
_func_sort_by5s���zFunctions._func_sort_bycC�&|�|ddgd�}|rt||d�SdS)Nr
r	Zmin_byr�)r�r��r7rrr�rrr�_func_min_byI��zFunctions._func_min_bycCr�)Nr
r	Zmax_byr�)r�r�r�rrr�_func_max_bySr�zFunctions._func_max_bycs����fdd�}|S)Ncs>���j|�}t|�j}��|�}|�vrt��||���|Sr)r�r�rHr0rJrrI)�xr�rNZ
jmespath_type�rFrr8r7rrr�^s

�z+Functions._create_key_func.<locals>.keyfuncr)r7rrFr8r�rr�rr�]s	zFunctions._create_key_funccCst�|d�S)N�unknown)�	TYPES_MAPr=)r7ZpyobjectrrrrJisz#Functions._convert_to_jmespath_typeN)'r0r1r2r.r:r6r?rCrGrKrr`rcrergrorqrtrurzr|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rJrrrrr4Cs|






























	
	r4)�	metaclass)r�rmZjmespathrZjmespath.compatrrlrr�rTrrHr r4rrrr�<module>s:��