403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/module_utils/common/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/module_utils/common/__pycache__/validation.cpython-311.pyc
�

���c�J��$�ddlmZmZmZeZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZmZmZmZd�Zd"d
�Zd#d�Zd#d�Zd#d�Zd#d�Z d#d�Z!d#d�Z"d#d�Z#d$d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d �Z-d!�Z.dS)%�)�absolute_import�division�print_functionN)�literal_eval)�	to_native)�json)�is_iterable)�jsonify)�human_to_bytes)�boolean)�binary_type�
integer_types�string_types�	text_typec��t|��s|g}tt|���|����S)aCount the number of occurrences of a key in a given dictionary

    :arg terms: String or iterable of values to check
    :arg parameters: Dictionary of parameters

    :returns: An integer that is the number of occurrences of the terms values
        in the provided dictionary.
    )r	�len�set�intersection)�terms�
parameterss  �K/usr/lib/python3.11/site-packages/ansible/module_utils/common/validation.py�count_termsrs=���u��������s�5�z�z�&�&�z�2�2�3�3�3�Fc�(�t|t��s|r|dfS|Stjd|��r|r|dfS|Stjd|��r|r|dfS|S	t	|��}|r|dfS|S#t
$r}|r	||fcYd}~S|cYd}~Sd}~wwxYw)Nz	\w\.\w+\(z
import \w+)�
isinstancer�re�searchr�	Exception)�value�locals�include_exceptions�result�es     r�	safe_evalr$*s����e�\�*�*���	!��4�=� ���	�y��u�%�%���	!��4�=� ���	�y���&�&���	!��4�=� ���	��e�$�$���	��D�>�!��M�������	��1�:���������������������s0�A0�.A0�0
B�:B�?B�B�B�Bc�L�g}|�|S|D]-}t||��}|dkr|�|���.|rkd�|D��}dd�|��z}|r)d�|d�|����}t	t|�����|S)a�Check mutually exclusive terms against argument parameters

    Accepts a single list or list of lists that are groups of terms that should be
    mutually exclusive with one another

    :arg terms: List of mutually exclusive parameters
    :arg parameters: Dictionary of parameters
    :kwarg options_context: List of strings of parent key names if ``terms`` are
        in a sub spec.

    :returns: Empty list or raises :class:`TypeError` if the check fails.
    N�c�8�g|]}d�|����S)�|)�join)�.0�checks  r�
<listcomp>z,check_mutually_exclusive.<locals>.<listcomp>^s"��:�:�:��S�X�X�e�_�_�:�:�:rz%parameters are mutually exclusive: %s�, �{0} found in {1}� -> �r�appendr)�format�	TypeErrorr)rr�options_context�resultsr+�count�	full_list�msgs        r�check_mutually_exclusiver9Fs����G��}����"�"���E�:�.�.���1�9�9��N�N�5�!�!�!���(�:�:�'�:�:�:�	�5��	�	�)�8L�8L�L���	O�$�+�+�C����_�1M�1M�N�N�C��	�#���'�'�'��Nrc�<�g}|�|S|D]-}t||��}|dkr|�|���.|rc|D]`}dd�|��z}|r)d�|d�|����}t	t|�����|S)a�Check each list of terms to ensure at least one exists in the given module
    parameters

    Accepts a list of lists or tuples

    :arg terms: List of lists of terms to check. For each list of terms, at
        least one is required.
    :arg parameters: Dictionary of parameters
    :kwarg options_context: List of strings of parent key names if ``terms`` are
        in a sub spec.

    :returns: Empty list or raises :class:`TypeError` if the check fails.
    Nrz$one of the following is required: %sr-r.r/r0)rrr4r5�termr6r8s       r�check_required_one_ofr<gs����G��}����!�!���D�*�-�-���A�:�:��N�N�4� � � ���,��	,�	,�D�8�4�9�9�T�?�?�J�C��
S�(�/�/��V�[�[��5Q�5Q�R�R���I�c�N�N�+�+�+��Nrc�t��g}|�|S|D]H}�fd�|D��}d�|D��}t|��dkrd|vr|�|���I|rc|D]`}dd�|��z}|r)d�|d�|����}t	t|�����|S)	aCheck each list of terms to ensure every parameter in each list exists
    in the given parameters.

    Accepts a list of lists or tuples.

    :arg terms: List of lists of terms to check. Each list should include
        parameters that are all required when at least one is specified
        in the parameters.
    :arg parameters: Dictionary of parameters
    :kwarg options_context: List of strings of parent key names if ``terms`` are
        in a sub spec.

    :returns: Empty list or raises :class:`TypeError` if the check fails.
    Nc�0��g|]}t|�����S�)r)r*�fieldrs  �rr,z+check_required_together.<locals>.<listcomp>�s#���C�C�C�U�+�e�Z�0�0�C�C�Crc��g|]
}|dk�|��S)rr?)r*�cs  rr,z+check_required_together.<locals>.<listcomp>�s��/�/�/�!��Q���A���rrz$parameters are required together: %sr-r.r/)rr1r)r2r3r)rrr4r5r;�counts�non_zeror8s `      r�check_required_togetherrE�s���� �G��}����%�%��C�C�C�C�d�C�C�C��/�/�v�/�/�/���x�=�=�1����F�{�{����t�$�$�$���,��	,�	,�D�8�4�9�9�T�?�?�J�C��
S�(�/�/��V�[�[��5Q�5Q�R�R���I�c�N�N�+�+�+��Nrc��i}|�|S|���D][\}}||vs||��g||<t|t��r|g}|D])}||vs||�||�|���*�\|r�|���D]z\}}t	|��dkrbd|�dd�|����}|r)d�|d�|����}tt|������{|S)a�For each key in requirements, check the corresponding list to see if they
    exist in parameters.

    Accepts a single string or list of values for each key.

    :arg requirements: Dictionary of requirements
    :arg parameters: Dictionary of parameters
    :kwarg options_context: List of strings of parent key names if ``requirements`` are
        in a sub spec.

    :returns: Empty dictionary or raises :class:`TypeError` if the
    Nrz"missing parameter(s) required by 'z': r-r.r/)	�itemsrrr1rr)r2r3r)	�requirementsrr4r"�keyr�required�missingr8s	         r�check_required_byrL�sO���F����
�$�*�*�,�,�	-�	-���e��j� � �J�s�O�$;����s���e�\�*�*�	��G�E��	-�	-�H��z�)�)�Z��-A�-I��s��"�"�8�,�,�,��	-��0�"�L�L�N�N�	0�	0�L�C���7�|�|�a����EH�S�S�$�)�)�T[�J\�J\�J\�]��"�W�,�3�3�C����_�9U�9U�V�V�C��	�#���/�/�/�	 ��Mrc��g}|�|S|���D]6\}}|�dd��}|r||vr|�|���7|rldd�t	|����z}|r)d�|d�|����}t
t|�����|S)aCheck all parameters in argument_spec and return a list of parameters
    that are required but not present in parameters.

    Raises :class:`TypeError` if the check fails

    :arg argument_spec: Argument spec dictionary containing all parameters
        and their specification
    :arg parameters: Dictionary of parameters
    :kwarg options_context: List of strings of parent key names if ``argument_spec`` are
        in a sub spec.

    :returns: Empty list or raises :class:`TypeError` if the check fails.
    NrJF�missing required arguments: %sr-r.r/)rG�getr1r)�sortedr2r3r)�
argument_specrr4rK�k�vrJr8s        r�check_required_argumentsrT�s����G������%�%�'�'�����A��5�5��U�+�+���	���+�+��N�N�1������(�.����6�'�?�?�1K�1K�K���	O�$�+�+�C����_�1M�1M�N�N�C��	�#���'�'�'��Nrc���g}|�|S|D]�}i}g|d<d}d}t|��dkr|\}}	}}n|\}}	}|rt|��}d|d<nd|d<||vrB|||	kr6|D]3}
t|
|��}|dkr|d�|
���4t|d��r=t|d��|kr$||d	<|	|d
<||d<|�|����|r�|D]�}|d	�d|d
�d
|d�dd�|d����}|r)d�|d�|����}tt
|�����|S)aTCheck parameters that are conditionally required

    Raises :class:`TypeError` if the check fails

    :arg requirements: List of lists specifying a parameter, value, parameters
        required when the given parameter is the specified value, and optionally
        a boolean indicating any or all parameters are required.

    :Example:

    .. code-block:: python

        required_if=[
            ['state', 'present', ('path',), True],
            ['someint', 99, ('bool_param', 'string_param')],
        ]

    :arg parameters: Dictionary of parameters

    :returns: Empty list or raises :class:`TypeError` if the check fails.
        The results attribute of the exception contains a list of dictionaries.
        Each dictionary is the result of evaluating each item in requirements.
        Each return dictionary contains the following keys:

            :key missing: List of parameters that are required but missing
            :key requires: 'any' or 'all'
            :key parameter: Parameter name that has the requirement
            :key value: Original value of the parameter
            :key requirements: Original required parameters

        :Example:

        .. code-block:: python

            [
                {
                    'parameter': 'someint',
                    'value': 99
                    'requirements': ('bool_param', 'string_param'),
                    'missing': ['string_param'],
                    'requires': 'all',
                }
            ]

    :kwarg options_context: List of strings of parent key names if ``requirements`` are
        in a sub spec.
    NrKrF��any�requires�all�	parameterrrHz is z but z of the following are missing: r-r.r/)rrr1r)r2r3r)
rHrr4r5�reqrK�max_missing_count�	is_one_ofrI�valr+r6r8s
             r�check_required_ifr_�s���`�G������$�$������	�����	��s�8�8�q�=�=�03�-�C��l�I�I�%(�"�C��l��	(� #�L� 1� 1��"'�G�J���"'�G�J���*����C��C�!7�!7�%�
5�
5��#�E�:�6�6���A�:�:��I�&�-�-�e�4�4�4���w�y�!�"�"�	$�s�7�9�+=�'>�'>�BS�'S�'S�#&�G�K� �"�G�G��&2�G�N�#��N�N�7�#�#�#���,��	,�	,�G���$�$�$�g�g�&6�&6�&6��
�8K�8K�8K�T�Y�Y�W^�_h�Wi�Mj�Mj�Mj�l�C��
S�(�/�/��V�[�[��5Q�5Q�R�R���I�c�N�N�+�+�+��Nrc���g}|�|S|D],}|�|��s|�|���-|r4dd�|��z}tt	|�����|S)a�This is for checking for required params when we can not check via
    argspec because we need more information than is simply given in the argspec.

    Raises :class:`TypeError` if any required parameters are missing

    :arg parameters: Dictionary of parameters
    :arg required_parameters: List of parameters to look for in the given parameters.

    :returns: Empty list or raises :class:`TypeError` if the check fails.
    NrNr-)rOr1r)r3r)r�required_parameters�missing_params�paramr8s     r�check_missing_parametersrdRs����N��"���$�)�)���~�~�e�$�$�	)��!�!�%�(�(�(���(�.����>�1J�1J�J���	�#���'�'�'��rT�c��t|t��r|S|rt|d���Sd�|��}t	t|�����)asVerify that the value is a string or convert to a string.

    Since unexpected changes can sometimes happen when converting to a string,
    ``allow_conversion`` controls whether or not the value will be converted or a
    TypeError will be raised if the value is not a string and would be converted

    :arg value: Value to validate or convert to a string
    :arg allow_conversion: Whether to convert the string and return it or raise
        a TypeError

    :returns: Original value if it is a string, the value converted to a string
        if allow_conversion=True, or raises a TypeError if allow_conversion=False.
    �surrogate_or_strict)�errorsz5'{0!r}' is not a string and conversion is not allowed)rrrr2r3)r�allow_conversionrc�prefixr8s     r�check_type_strrkos^���%��&�&�����>���'<�=�=�=�=�
A�
H�
H��
O�
O�C�
�I�c�N�N�
#�
#�#rc�6�t|t��r|St|t��r|�d��St|t��st|t
��rt
|��gStdt|��z���)a�Verify that the value is a list or convert to a list

    A comma separated string will be split into a list. Raises a :class:`TypeError`
    if unable to convert to a list.

    :arg value: Value to validate or convert to a list

    :returns: Original value if it is already a list, single item list if a
        float, int, or string without commas, or a multi-item list if a
        comma-delimited string.
    �,z %s cannot be converted to a list)	r�listr�split�int�float�strr3�type�rs r�check_type_listru�s����%��������%��&�&���{�{�3����	�E�3�	�	��:�e�U�#;�#;���E�
�
�|��
�6��e���D�
E�
E�Erc�f�t|t��r|St|t���rf|�d��rY	t	j|��S#t$r7t|t��d���\}}|�td���|cYSwxYwd|vr�g}g}d}d}|�	��D]�}|r|�
|��d}�|dkrd}�%|s|d	vr|}�.|r	||krd}�9|s3|d
vr/d�|��}|r|�
|��g}�n|�
|����d�|��}|r|�
|��td�|D����Std
���tdt|��z���)aVerify that value is a dict or convert it to a dict and return it.

    Raises :class:`TypeError` if unable to convert to a dict

    :arg value: Dict or string to convert to a dict. Accepts ``k1=v2, k2=v2``.

    :returns: value converted to a dictionary
    �{T)r!Nz'unable to evaluate string as dictionary�=F�\)�'�")rm� rec3�BK�|]}|�dd��V��dS)rxr&N)ro)r*�xs  r�	<genexpr>z"check_type_dict.<locals>.<genexpr>�s.����8�8�A�����Q���8�8�8�8�8�8rz7dictionary requested, could not parse JSON or key=valuez %s cannot be converted to a dict)
r�dictr�
startswithr�loadsrr$r3�stripr1r)rs)	rr"�exc�fields�field_buffer�in_quote�	in_escaperBr@s	         r�check_type_dictr��s���%��������%��&�&�%W����C� � �$	W�
��z�%�(�(�(���
�
�
� )�%����D� Q� Q� Q�
����?�#�$M�N�N�N��
�
�
�	
����
�E�\�\��F��L��H��I��[�[�]�]�
+�
+���+� �'�'��*�*�*� %�I�I��$�Y�Y� $�I�I�!�
+�a�;�&6�&6� �H�H��+�(�a�-�-�$�H�H�!�+�a�:�o�o��G�G�L�1�1�E��-��
�
�e�,�,�,�#%�L�L� �'�'��*�*�*�*��G�G�L�)�)�E��
%��
�
�e�$�$�$��8�8��8�8�8�8�8�8��U�V�V�V�
�6��e���D�
E�
E�Es�A�>B�Bc���t|t��r|St|t��st|ttf��rt|��St
dt|��z���)aXVerify that the value is a bool or convert it to a bool and return it.

    Raises :class:`TypeError` if unable to convert to a bool

    :arg value: String, int, or float to convert to bool. Valid booleans include:
         '1', 'on', 1, '0', 0, 'n', 'f', 'false', 'true', 'y', 't', 'yes', 'no', 'off'

    :returns: Boolean True or False
    z %s cannot be converted to a bool)r�boolrrprqrr3rsrts r�check_type_boolr��sh���%��������%��&�&��*�U�S�%�L�*I�*I���u�~�~��
�6��e���D�
E�
E�Erc���t|t��r|St|t��r 	t|��S#t$rYnwxYwtdt
|��z���)z�Verify that the value is an integer and return it or convert the value
    to an integer and return it

    Raises :class:`TypeError` if unable to convert to an int

    :arg value: String or int to convert of verify

    :return: int of given value
    z %s cannot be converted to an int)rrrrp�
ValueErrorr3rsrts r�check_type_intr��sz���%��'�'�����%��&�&��	��u�:�:����	�	�	��D�	�����6��e���D�
E�
E�Es�=�
A
�	A
c���t|t��r|St|tttf��r 	t|��S#t
$rYnwxYwt
dt|��z���)z�Verify that value is a float or convert it to a float and return it

    Raises :class:`TypeError` if unable to convert to a float

    :arg value: float, int, str, or bytes to verify or convert and return.

    :returns: float of given value.
    z!%s cannot be converted to a float)rrqr
rrpr�r3rsrts r�check_type_floatr��s����%��������%�+�y�#�6�7�7��	���<�<����	�	�	��D�	�����7�$�u�+�+�E�
F�
F�Fs�A
�

A�Ac��t|��}tj�tj�|����S)zgVerify the provided value is a string or convert it to a string,
    then return the expanded path
    )rk�os�path�
expanduser�
expandvarsrts r�check_type_pathr�s7��
�5�!�!�E�
�7���b�g�0�0��7�7�8�8�8rc��|S)zReturns the raw valuer?rts r�check_type_rawr�s���Lrc�|�	t|��S#t$r tdt|��z���wxYw)zpConvert a human-readable string value to bytes

    Raises :class:`TypeError` if unable to covert the value
    z&%s cannot be converted to a Byte value�rr�r3rsrts r�check_type_bytesr�sO��
P��e�$�$�$���P�P�P��@�4��;�;�N�O�O�O�P���s��*;c��	t|d���S#t$r tdt|��z���wxYw)z�Convert a human-readable string bits value to bits in integer.

    Example: ``check_type_bits('1Mb')`` returns integer 1048576.

    Raises :class:`TypeError` if unable to covert the value.
    T)�isbitsz%%s cannot be converted to a Bit valuer�rts r�check_type_bitsr�*sT��O��e�D�1�1�1�1���O�O�O��?�$�u�+�+�M�N�N�N�O���s��*=c��t|ttf��r|���St|tt
tf��rt|��Stdt|��z���)z�Return a jsonified string. Sometimes the controller turns a json string
    into a dict/list so transform it back into json here

    Raises :class:`TypeError` if unable to covert the value

    z'%s cannot be converted to a json string)
rrr
r�rn�tupler�r
r3rsrts r�check_type_jsonargr�7sh���%�)�[�1�2�2���{�{�}�}��	�E�D�%��.�	/�	/���u�~�~��
�=��U���K�
L�
L�Lr)NF)N)TNre)/�
__future__rrrrs�
__metaclass__r�r�astr�ansible.module_utils._textr�(ansible.module_utils.common._json_compatr�'ansible.module_utils.common.collectionsr	�+ansible.module_utils.common.text.convertersr
�+ansible.module_utils.common.text.formattersr�)ansible.module_utils.parsing.convert_boolr�ansible.module_utils.sixr
rrrrr$r9r<rErLrTr_rdrkrur�r�r�r�r�r�r�r�r�r?rr�<module>r�s��
A�@�@�@�@�@�@�@�@�@��
�	�	�	�	�	�	�	�	�������0�0�0�0�0�0�9�9�9�9�9�9�?�?�?�?�?�?�?�?�?�?�?�?�F�F�F�F�F�F�=�=�=�=�=�=�������������
4�
4�
4� ����8����B����D!�!�!�!�H%�%�%�%�P����BY�Y�Y�Y�x����:$�$�$�$�0F�F�F�.3F�3F�3F�lF�F�F�&F�F�F�,G�G�G�*9�9�9����
P�P�P�
O�
O�
O�M�M�M�M�Mr

Youez - 2016 - github.com/yon3zu
LinuXploit