HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/thorium/__pycache__/reg.cpython-310.pyc
o

�N�g�@sDdZddlZddd�Zdd�Zdd	d
�Zdd�Zd
d�Zdd�ZdS)z�
Used to manage the thorium register. The thorium register is where compound
values are stored and computed, such as averages etc.
�N�set�list)�set_�list_c	Cs�|iddd�}|tvrit|<t�t|d<tD]=}tjj�|d|�rUz|dd�|�}Wnty?|d�|�}Ynw|durFd}||d	|<t|d�	|�q|S)
z�
    Add a value to the named set

    USAGE:

    .. code-block:: yaml

        foo:
          reg.set:
            - add: bar
            - match: my/custom/event
    �T��name�changesZcomment�result�val�tag�dataN�Noner	)
�__reg__r�
__events__�salt�utils�stringutils�
expr_match�get�KeyError�add)rr�match�ret�eventr�r�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/thorium/reg.pyrs"
��rFc
	Cs�|iddd�}t|t�s|�d�}|tvrit|<gt|d<tD]H}z|dd}Wn
ty8|d}Ynwtjj�	|d|�rii}|D]}	|	|vr_||	||	<|dur_|dd|d	<qGt|d�
|�q!|d
kr|t|dd|�t|d<|S)a�
    Add the specified values to the named list

    If ``stamp`` is True, then the timestamp from the event will also be added
    if ``prune`` is set to an integer higher than ``0``, then only the last
    ``prune`` values will be kept in the list.

    USAGE:

    .. code-block:: yaml

        foo:
          reg.list:
            - add: bar
            - match: my/custom/event
            - stamp: True
    rTr�,rr
rZ_stamp�timerN)�
isinstancer�splitrrrrrrr�append)
rrrZstampZprunerr�
event_data�item�keyrrrr,s2

���rc	Cs|iddd�}|tvr!it|<dt|d<dt|d<dt|d<tD]Z}z|dd}Wn
ty:|d}Ynwtjj�|d	|�r}||vrYzt|�}Wn	tyXYq#wt|d|7<t|dd
7<t|dt|dt|d<q#|S)aE
    Accept a numeric value from the matched events and store a running average
    of the values in the given register. If the specified value is not numeric
    it will be skipped

    USAGE:

    .. code-block:: yaml

        foo:
          reg.mean:
            - add: data_field
            - match: my/custom/event
    rTrrr�total�countr
r�)	rrrrrrr�int�
ValueError)rrrrrr"�comprrr�meanVs0�� �r+cCs&|iddd�}|tvrt|��|S)z�
    Clear the namespace from the register

    USAGE:

    .. code-block:: yaml

        clearns:
          reg.clear:
            - name: myregister
    rTr)r�clear�rrrrrr,|sr,cCs |iddd�}|tvrt|=|S)z�
    Delete the namespace from the register

    USAGE:

    .. code-block:: yaml

        deletens:
          reg.delete:
            - name: myregister
    rTr)rr-rrr�delete�sr.)Fr)	�__doc__Zsalt.utils.stringutilsrZ__func_alias__rrr+r,r.rrrr�<module>s�
*&