HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/jmespath/__pycache__/functions.cpython-37.pyc
B

�P�e�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��C/opt/alt/python37/lib/python3.7/site-packages/jmespath/functions.py�_record_signature'sz$signature.<locals>._record_signaturer)rrr)rrr&srcs$eZdZ�fdd�Zdd�Z�ZS)�FunctionRegistrycs |��tt|��|||�dS)N)�_populate_function_table�superr�__init__)�cls�name�bases�attrs)�	__class__rrr!.szFunctionRegistry.__init__cCsZi}xJt|�D]>\}}|�d�s"qt|dd�}|dk	r||d�||dd�<qW||_dS)NZ_func_r)�functionr�)r�
startswith�getattr�FUNCTION_TABLE)r"Zfunction_tabler#�methodrrrrr2s
z)FunctionRegistry._populate_function_table)�__name__�
__module__�__qualname__r!r�
__classcell__rr)r&rr-src@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
ddd"gi�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
d"gdd��d7d8��Ze
d
dd/gi�d9d:��Ze
d
d/dgi�d;d<��Ze
d
dgi�d=d>��Ze
d
d"gi�d?d@��Ze
d
d"gi�dAdB��Z e
d
gi�dCdD��Z!e
d
dgid
d2gi�dEdF��Z"e
d
dgid
d2gi�dGdH��Z#e
d
dgid
d2gi�dIdJ��Z$dKdL�Z%dMdN�Z&dOS)P�	FunctionscCs^y|j|}Wn"tk
r0t�d|��YnX|d}|d}|�|||�||f|��S)NzUnknown function: %s()r'r)r+�KeyErrorrZUnknownFunctionError�_validate_arguments)�self�
function_nameZ
resolved_args�specr'rrrr�
call_functionHszFunctions.call_functioncCsn|r:|d�d�r:t|�t|�kr`t�t|�t|�|��n&t|�t|�kr`t�t|�t|�|��|�|||�S)N����variadic)�get�lenrZVariadictArityErrorZ
ArityError�_type_check)r4�argsrr5rrrr3SszFunctions._validate_argumentscCs<x6tt|��D]&}||d}|r|�||||�qWdS)N�types)�ranger;�_type_check_single)r4�actualrr5�i�
allowed_typesrrrr<]s
zFunctions._type_checkcCsN|�|�\}}t|�j}||kr6t�|||�|�|��|rJ|�||||�dS)N)�_get_allowed_pytypes�typer-r�JMESPathTypeError�_convert_to_jmespath_type�_subtype_check)r4�currentr>r5rC�allowed_subtypes�actual_typenamerrrr@ds
zFunctions._type_check_singlecCsdg}g}xR|D]J}|�dd�}t|�dkrB|\}}|�t|�n|d}|�t|�qW||fS)N�-��r)�splitr;�append�REVERSE_TYPES_MAP�extend)r4r>rCrJ�t�type_�subtyperrrrD{s
zFunctions._get_allowed_pytypesc
Cs�t|�dkrF|d}x�|D]&}t|�j}||krt�||||��qWn~t|�dkr�|r�t|d�j}x.|D]}||krj|}	PqjWt�||d||��x.|D]&}t|�j}||	kr�t�||||��q�WdS)NrMr)r;rEr-rrF)
r4rIrJr>r5�elementrK�first�subtypes�allowedrrrrH�s(




zFunctions._subtype_checkr>r
cCst|�S)N)�abs)r4�argrrr�	_func_abs�szFunctions._func_abszarray-numbercCs |rt|�tt|��SdSdS)N)�sumrr;)r4r[rrr�	_func_avg�szFunctions._func_avgT)r>r9cGsx|D]}|dk	r|SqWdS)Nr)r4r�argumentrrr�_func_not_null�s
zFunctions._func_not_nullcCst|t�r|S|gSdS)N)�
isinstancer
)r4r[rrr�_func_to_array�s
zFunctions._func_to_arraycCs"t|t�r|Stj|dtd�SdS)N)�,�:)�
separators�default)ra�STRING_TYPE�json�dumpsr)r4r[rrr�_func_to_string�s
zFunctions._func_to_stringcCsrt|tttf�rdS|dkr dSt|ttf�r2|Syt|�Stk
rlyt|�Stk
rfdSXYnXdS)N)rar
rrrr�
ValueError)r4r[rrr�_func_to_number�szFunctions._func_to_numberrr	cCs||kS)Nr)r4�subject�searchrrr�_func_contains�szFunctions._func_containsrcCst|�S)N)r;)r4r[rrr�_func_length�szFunctions._func_lengthcCs
|�|�S)N)�endswith)r4rn�suffixrrr�_func_ends_with�szFunctions._func_ends_withcCs
|�|�S)N)r))r4rnrrrrr�_func_starts_with�szFunctions._func_starts_withcCs(t|t�r|ddd�Stt|��SdS)Nr8)rargr
�reversed)r4r[rrr�
_func_reverse�s
zFunctions._func_reversecCs
t�|�S)N)�math�ceil)r4r[rrr�
_func_ceil�szFunctions._func_ceilcCs
t�|�S)N)rw�floor)r4r[rrr�_func_floor�szFunctions._func_floorzarray-stringcCs
|�|�S)N)�join)r4�	separatorrrrr�
_func_join�szFunctions._func_joinrcCs*g}x |D]}|�|�|j|��q
W|S)N)rP�visit�
expression)r4rr[�resultrVrrr�	_func_map�s
zFunctions._func_mapcCs|rt|�SdSdS)N)�max)r4r[rrr�	_func_max�szFunctions._func_maxcGs i}x|D]}|�|�q
W|S)N)�update)r4r�mergedr[rrr�_func_merges
zFunctions._func_mergecCs|rt|�SdSdS)N)�min)r4r[rrr�	_func_min
szFunctions._func_mincCstt|��S)N)r
�sorted)r4r[rrr�
_func_sortszFunctions._func_sortcCst|�S)N)r])r4r[rrr�	_func_sumszFunctions._func_sumcCst|���S)N)r
�keys)r4r[rrr�
_func_keysszFunctions._func_keyscCst|���S)N)r
�values)r4r[rrr�_func_values"szFunctions._func_valuescCsZt|t�rdSt|t�rdSt|t�r*dSt|t�r8dSt|ttf�rJdS|dkrVdSdS)Nr	rrrr
r)rargrr
rrr)r4r[rrr�
_func_type&s



zFunctions._func_typecCsf|s|S|�t|�|j|d��j�}|dkrFt�d|d|ddg��|�||gd�}tt	||d��S)Nr)r
r	Zsort_byr	r
)�key)
rGrErr�r-rrF�_create_key_funcr
r�)r4rrZ
required_type�keyfuncrrr�
_func_sort_by5szFunctions._func_sort_bycCs*|�|ddgd�}|r"t||d�SdSdS)Nr
r	Zmin_by)r�)r�r�)r4rrr�rrr�_func_min_byIszFunctions._func_min_bycCs*|�|ddgd�}|r"t||d�SdSdS)Nr
r	Zmax_by)r�)r�r�)r4rrr�rrr�_func_max_bySszFunctions._func_max_bycs����fdd�}|S)Ncs>���j|�}t|�j}��|�}|�kr:t��||���|S)N)rr�rEr-rGrrF)�xr�rKZ
jmespath_type)rCrr5r4rrr�^s

z+Functions._create_key_func.<locals>.keyfuncr)r4rrCr5r�r)rCrr5r4rr�]s	zFunctions._create_key_funccCst�|d�S)N�unknown)�	TYPES_MAPr:)r4ZpyobjectrrrrGisz#Functions._convert_to_jmespath_typeN)'r-r.r/r+r7r3r<r@rDrHrr\r^r`rbrjrlrorprsrtrvryr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�rGrrrrr1CsF



r1)�	metaclass)rwrh�jmespathrZjmespath.compatrrgrr�rQrrErr1rrrr�<module>s4