HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/jmespath/__pycache__/functions.cpython-310.pyc
o

�N�g�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�basesZattrs��	__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)r6�argsrr7rrrr5Ss���zFunctions._validate_argumentscCs8tt|��D]}||d}|r|�||||�qdS)N�types)�ranger=�_type_check_single)r6�actualrr7�i�
allowed_typesrrrr>]s���zFunctions._type_checkcCsR|�|�\}}t|�j}||vrt�|||�|�|��|r'|�||||�dSdSr)�_get_allowed_pytypes�typer/r�JMESPathTypeError�_convert_to_jmespath_type�_subtype_check)r6�currentr@r7rE�allowed_subtypes�actual_typenamerrrrBds

���zFunctions._type_check_singlecCs`g}g}|D]%}|�dd�}t|�dkr |\}}|�t|�n|d}|�t|�q||fS)N�-��r)�splitr=�append�REVERSE_TYPES_MAP�extend)r6r@rErL�tZtype_�subtyperrrrF{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)NrOr)r=rGr/rrH)
r6rKrLr@r7�elementrM�firstZsubtypes�allowedrrrrJ�s:
�����
���zFunctions._subtype_checkr@r
cC�t|�Sr)�abs�r6�argrrr�	_func_abs��zFunctions._func_abszarray-numbercCs|rt|�tt|��SdSr)�sumrr=r\rrr�	_func_avg�szFunctions._func_avgT)r@r;cGs|D]
}|dur|SqdSrr)r6r�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)rd�STRING_TYPE�json�dumpsrr\rrr�_func_to_string�s

�zFunctions._func_to_stringcCsrt|tttf�r
dS|durdSt|ttf�r|Szt|�WSty8zt|�WYSty7YYdSwwr)rdr
rrrr�
ValueErrorr\rrr�_func_to_number�s
��zFunctions._func_to_numberrr	cCs||vSrr)r6�subject�searchrrr�_func_contains�r_zFunctions._func_contains)r	rrcCrZr)r=r\rrr�_func_length�r_zFunctions._func_lengthcC�
|�|�Sr)�endswith�r6rq�suffixrrr�_func_ends_with��
zFunctions._func_ends_withcCrtr)r+rvrrr�_func_starts_with�ryzFunctions._func_starts_withcCs$t|t�r|ddd�Stt|��S)Nr:)rdrjr
�reversedr\rrr�
_func_reverse�s
zFunctions._func_reversecC�
t�|�Sr)�math�ceilr\rrr�
_func_ceil�ryzFunctions._func_ceilcCr}r)r~�floorr\rrr�_func_floor�ryzFunctions._func_floorzarray-stringcCrtr)�join)r6�	separatorrrrr�
_func_join�ryzFunctions._func_joinrcCs&g}|D]}|�|�|j|��q|Sr)rR�visit�
expression)r6rr]�resultrWrrr�	_func_map�szFunctions._func_mapcC�|rt|�SdSr)�maxr\rrr�	_func_max��zFunctions._func_maxrcGsi}|D]}|�|�q|Sr)�update)r6rZmergedr]rrr�_func_mergeszFunctions._func_mergecCr�r)�minr\rrr�	_func_min
r�zFunctions._func_mincCstt|��Sr)r
�sortedr\rrr�
_func_sort�zFunctions._func_sortcCrZr)r`r\rrr�	_func_sumr_zFunctions._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)rdrjr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)
rIrGr�r�r/rrH�_create_key_funcr
r�)r6rrZ
required_type�keyfuncrrr�
_func_sort_by5s���zFunctions._func_sort_bycC�&|�|ddgd�}|rt||d�SdS)Nr
r	Zmin_byr�)r�r��r6rrr�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�rGr/rIrrH)�xr�rMZ
jmespath_type�rErr7r6rrr�^s

�z+Functions._create_key_func.<locals>.keyfuncr)r6rrEr7r�rr�rr�]s	zFunctions._create_key_funccCst�|d�S)N�unknown)�	TYPES_MAPr<)r6ZpyobjectrrrrIisz#Functions._convert_to_jmespath_typeN)'r/r0r1r-r9r5r>rBrFrJrr^rarcrermrorrrsrxrzr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rIrrrrr3Cs|






























	
	r3)�	metaclass)r~rkZjmespathrZjmespath.compatrrjrr�rSrrGr r3rrrr�<module>s:��