Hacked By AnonymousFox

Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/cerberus/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/cerberus/__pycache__/schema.cpython-311.pyc

�

m��f�G���ddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZmZmZmZGd�de��ZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��Ze��e��cZZdS)�)�absolute_import)�warn)�errors)�	_str_type�Callable�Hashable�Mapping�MutableMapping�Sequence)�get_Validator_class�validator_factory�mapping_hash�TypeDefinitionc��eZdZdS)�_AbortN)�__name__�
__module__�__qualname__���F/opt/imunify360/venv/lib64/python3.11/site-packages/cerberus/schema.pyrrs�������Drrc��eZdZdZdS)�SchemaErrorz_
    Raised when the validation schema is missing, has the wrong format or contains
    errors.N)rrr�__doc__rrrrrs��������	�Drrc����eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ed���Zed
���Zed���Zdd�Zd�Zd�Zed���Zd�Zdd�Zd�Z�xZS)�DefinitionSchemaz1A dict-subclass for caching of validated schemas.c�v��dt��vr�tdt��atj���}|�tdtfd��tdtfd��d���|t_tt|���|��S)N�SchemaValidator�callabler�hashable)rr )
�globalsr
�SchemaValidatorMixinr�
types_mapping�copy�updaterrr�superr�__new__)�cls�args�kwargsr#�	__class__s    �rr'zDefinitionSchema.__new__%s�����G�I�I�-�-�/�0A�CW�X�X�O�+�9�>�>�@�@�M�� � � .�z�H�;�� K� K� .�z�H�;�� K� K���
�
�
�-:�O�)��%�s�+�+�3�3�C�8�8�8rc�d�t|t����std���||_t|t��r|j�||��}t|t��sK	t|��}n:#t$r-ttj�
|�����wxYwt|��|_t!d|jtj||���|_|�|��}|�|��||_dS)z�
        :param validator: An instance of Validator-(sub-)class that uses this
                          schema.
        :param schema: A definition-schema as ``dict``. Defaults to an empty
                       one.
        z0validator argument must be a Validator-instance.N)�
allow_unknown�
error_handler�
target_schema�target_validator)�
isinstancer�RuntimeError�	validatorr�schema_registry�getr	�dict�	Exceptionrr�SCHEMA_ERROR_DEFINITION_TYPE�format�SchemaValidationSchema�validation_schemar�SchemaErrorHandler�schema_validator�expand�validate�schema)�selfr3r@s   r�__init__zDefinitionSchema.__init__4s1���)�%8�%:�%:�;�;�	V��T�U�U�U�"����f�i�(�(�	C��.�2�2�6�6�B�B�F��&�'�*�*�	V�
V��f�������
V�
V�
V�!�&�"E�"L�"L�V�"T�"T�U�U�U�
V����"8�	�!B�!B��� /���0� �3� �&�!
�!
�!
������V�$�$���
�
�f��������s�9B	�	7Cc��|j���}	||=|j|=dS#t$rtd|z���t$r}|�d}~wwxYw)Nz Schema has no field '%s' defined)r@r$�
ValueErrorrr7)rA�key�_new_schema�es    r�__delitem__zDefinitionSchema.__delitem__Us����k�&�&�(�(��	!��C� ���C� � � ���	H�	H�	H��@�3�F�G�G�G��	�	�	��G�����	���s�(�%A�
A�Ac��|j|S�N)r@)rA�items  r�__getitem__zDefinitionSchema.__getitem__`s���{�4� � rc�*�t|j��SrJ)�iterr@�rAs r�__iter__zDefinitionSchema.__iter__cs���D�K� � � rc�*�t|j��SrJ)�lenr@rOs r�__len__zDefinitionSchema.__len__fs���4�;���rc� �t|��SrJ)�strrOs r�__repr__zDefinitionSchema.__repr__is���4�y�y�rc��|�d|i��d}|�||i��||j|<dS�Nr)r>r?r@)rArE�values   r�__setitem__zDefinitionSchema.__setitem__lsD�����Q��J�'�'��*���
�
�s�E�l�#�#�#� ���C���rc�N�t|d��rt|j��SdS)Nr@zNo schema data is set yet.)�hasattrrUr@rOs r�__str__zDefinitionSchema.__str__qs*���4��"�"�	0��t�{�#�#�#�/�/rc�f�|�|j|j�����SrJ)r+r3r@r$rOs rr$zDefinitionSchema.copyws&���~�~�d�n�d�k�.>�.>�.@�.@�A�A�Arc��	|�|��}|�|��}n#t$rYnwxYw|�|��}|SrJ)�_expand_logical_shortcuts�_expand_subschemasr7�_rename_deprecated_rulenames)r(r@s  rr>zDefinitionSchema.expandzsi��	��2�2�6�:�:�F��+�+�F�3�3�F�F���	�	�	��D�	�����1�1�&�9�9���
s�*-�
:�:c���d��|���D]q\}}�fd�|D��D]]}|�dd��\}}|�|gi��||D]}||�||i��� ||=�^�r|S)z�
        Expand agglutinated rules in a definition-schema.

        :param schema: The schema-definition to expand.
        :return: The expanded schema-definition.
        c�V�t|t��o|�d��S)N)�allof_�anyof_�noneof_�oneof_)r1r�
startswith)�xs r�
is_of_rulez>DefinitionSchema._expand_logical_shortcuts.<locals>.is_of_rule�s,���a��+�+�����9�1�1�
rc�*��g|]}�|���
|��Srr)�.0rjrks  �r�
<listcomp>z>DefinitionSchema._expand_logical_shortcuts.<locals>.<listcomp>�s&���>�>�>�!�
�
�1�
�
�>�A�>�>�>r�_�)�items�splitr%�append)	r(r@�field�rules�of_rule�operator�rulerYrks	        @rr`z*DefinitionSchema._expand_logical_shortcuts�s����	�	�	�
#�L�L�N�N�	#�	#�L�E�5�>�>�>�>�u�>�>�>�
#�
#��!(���s�A�!6�!6���$����h��^�,�,�,�"�7�^�:�:�E��(�O�*�*�D�%�=�9�9�9�9��'�N�N�
#��
rc	������fd�}��fd�}�D�]5�|��sng|��r+|���d����d<n2|�d��di��d��d<dD]>}|��vr2|�d��|i��d��|<�?dD]|}|��vrpt��|t��s�.g}��|D]2}|�|�d|i��d���3|��|<�}��7�S)Nc�N��t��t��o	d��vS)Nr@�r1r	�rtr@s��r�has_schema_rulez<DefinitionSchema._expand_subschemas.<locals>.has_schema_rule�s%����f�U�m�W�5�5�S�(�f�U�m�:S�Src���	td���d���D����S#t$rYdSwxYw)zw
            Tries to determine heuristically if the schema-constraints are aimed to
            mappings.
            c3�@K�|]}t|t��V��dSrJr{�rmrjs  r�	<genexpr>zRDefinitionSchema._expand_subschemas.<locals>.has_mapping_schema.<locals>.<genexpr>�s=������/0�J�q�'�*�*������rr@F)�all�values�	TypeErrorr|s��r�has_mapping_schemaz?DefinitionSchema._expand_subschemas.<locals>.has_mapping_schema�so���

����4:�5�M�(�4K�4R�4R�4T�4T���������
�
�
��u�u�
���s�6:�
A�Ar@r)�	keysrules�valuesrules�	keyschema�valueschema)�allof�anyofrq�noneof�oneof)r>r1rrs)r(r@r}r�rx�new_rules_definitionrKrts `     @rraz#DefinitionSchema._expand_subschemas�s�����	T�	T�	T�	T�	T�	T�
	�
	�
	�
	�
	�
	��	?�	?�E�"�?�$�$�
V��#�#�%�%�
V�*-�*�*�V�E�]�8�5L�*M�*M��u�
�h�'�'�*-�*�*�a����x�9P�5Q�*R�*R�ST�*U��u�
�h�'�Q�
R�
R���6�%�=�(�(�*-�*�*�a����t�9L�5M�*N�*N�q�*Q�F�5�M�$�'��F�
?�
?���6�%�=�(�(�%�f�U�m�D�&9�8�D�D�!� �+-�(� &�u�
�d� 3�N�N��,�3�3�C�J�J��4�y�4I�4I�!�4L�M�M�M�M�*>�F�5�M�$�'��
?��
rNc�8�|j�||��SrJ)r@r5)rArK�defaults   rr5zDefinitionSchema.get�s���{���t�W�-�-�-rc�4�|j���SrJ)r@rqrOs rrqzDefinitionSchema.items�s���{� � �"�"�"rc�X�	|�|��}|j���}|�|��|�|��||_dS#t
$r-t
tj�	|�����t$r}|�d}~wwxYwrJ)r>r@r$r%r?rDrrr8r9r7)rAr@rFrGs    rr%zDefinitionSchema.update�s���
	&��[�[��(�(�F��+�*�*�,�,�K����v�&�&�&��M�M�+�&�&�&�&�D�K�K�K���	R�	R�	R��f�A�H�H��P�P�Q�Q�Q��	�	�	��G�����	���s�AA#�#?B)�"B$�$B)c�^�|���D]�\}}t|t��r�dD]y\}}||vr�
||vrtd���t	d�||���t��||||||<||�|���z��|S)N))r�r�)r3�
check_with)r�r�zTThe rule '{new}' is also present with its old name '{old}' in the same set of rules.zrThe rule '{old}' was renamed to '{new}'. The old name will not be available in the next major release of Cerberus.)�old�new)rqr1rUr2rr9�DeprecationWarning�pop)r@rtrur�r�s     rrbz-DefinitionSchema._rename_deprecated_rulenames�s���"�L�L�N�N�	'�	'�L�E�5��%��%�%�
���
'�
'���S�
�e�#�#���%�<�<�&�A����
� � &��3�C�� 8� 8�&�	���&,�E�]�3�%7��u�
�c�"��u�
�!�!�#�&�&�&�&�+
'�.�
rc�8�t|j��|_dSrJ)r:r3r;rOs r�regenerate_validation_schemaz-DefinitionSchema.regenerate_validation_schema�s��!7���!G�!G����rc���|�|j}t|��t|jj��f}||jjvr6|�|��|jj�|��dSdS)ap
        Validates a schema that defines rules against supported rules.

        :param schema: The schema to be validated as a legal cerberus schema
                       according to the rules of the assigned Validator object.
                       Raises a :class:`~cerberus.base.SchemaError` when an invalid
                       schema is encountered.
        N)r@rr3r#�_valid_schemas�	_validate�add)rAr@�_hashs   rr?zDefinitionSchema.validate�sx���>��[�F��f�%�%�|�D�N�4P�'Q�'Q�R�����5�5�5��N�N�6�"�"�"��N�)�-�-�e�4�4�4�4�4�6�5rc���t|t��r |jj�||��}i}|���D]s\}}t|t��rt�||��||<�9i}|���D]\}}|||�dd��<�|||<�t|�|d���st|jj
���dS)N� roF��	normalize)r1rr3r4r5rq�rules_set_registry�replacer=rr)rAr@�test_schemartru�
test_rulesrx�
constraints        rr�zDefinitionSchema._validates���f�i�(�(�	H��^�3�7�7���G�G�F���"�L�L�N�N�	0�	0�L�E�5��%��+�+�
0�%7�%;�%;�E�5�%I�%I��E�"�"��
�(-���
�
�D�D�$�D�*�9C�J�t�|�|�C��5�5�6�6�%/��E�"�"��$�$�[�E�$�B�B�	<��d�3�:�;�;�;�	<�	<rrJ)rrrrr'rBrHrLrPrSrVrZr]r$�classmethodr>r`rar5rqr%�staticmethodrbr�r?r��
__classcell__�r+s@rrr"s��������;�;�
9�
9�
9�
9�
9����B	!�	!�	!�!�!�!�!�!�!� � � ����!�!�!�
0�0�0�B�B�B��
�
��[�
�����[��,�%�%��[�%�N.�.�.�.�#�#�#�&�&�&�����\��<H�H�H�5�5�5�5� <�<�<�<�<�<�<rrc�$�eZdZifd�Zd�Zd�ZdS)�UnvalidatedSchemac�\�t|t��st|��}||_dSrJ)r1r	r6r@�rAr@s  rrBzUnvalidatedSchema.__init__s*���&�'�*�*�	"��&�\�\�F�����rc��dSrJrr�s  rr?zUnvalidatedSchema.validate$s���rc�Z�|�|j�����SrJ)r+r@r$rOs rr$zUnvalidatedSchema.copy's$���~�~�d�k�.�.�0�0�1�1�1rN)rrrrBr?r$rrrr�r�sI������ �����

�
�
�2�2�2�2�2rr�c��eZdZd�ZdS)r:c�&�d|jdd�|_dS)NFr6)r-r@�type)rur@)rAr3s  rrBzSchemaValidationSchema.__init__.s��"��o��
�
����rN)rrrrBrrrr:r:-s#������
�
�
�
�
rr:c���eZdZdZ�fd�Zed���Zed���Zed���Zed���Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Z�xZS)r"zi
    This validator mixin provides mechanics to validate schemas passed to a Cerberus
    validator.
    c����|�dt����|�dt����tt|��j|i|��dS)N�known_rules_set_refs�known_schema_refs)�
setdefault�setr&r"rB)rAr)r*r+s   �rrBzSchemaValidatorMixin.__init__<sb������0�#�%�%�8�8�8����-�s�u�u�5�5�5�2��"�D�)�)�2�D�C�F�C�C�C�C�Crc��|jdS)z7The encountered references to rules set registry items.r���_configrOs rr�z)SchemaValidatorMixin.known_rules_set_refsAs���|�2�3�3rc��|jdS)z4The encountered references to schema registry items.r�r�rOs rr�z&SchemaValidatorMixin.known_schema_refsFs���|�/�0�0rc��|jdS)z#The schema that is being validated.r/r�rOs rr/z"SchemaValidatorMixin.target_schemaKs���|�O�,�,rc��|jdS)z.The validator whose schema is being validated.r0r�rOs rr0z%SchemaValidatorMixin.target_validatorPs���|�.�/�/rc�L�t|t��rc||jvrdS|j�|��|jj�|��}|�|�|d|z��dS|}td|i��t|jj	��f}||jj
vrdS|�|d|jj���}||d���|j
r|�|j
��dS|jj
�|��dS)Nz"Rules set definition %s not found.�turingF��document_crumbr-r@r�)r1rr�r�r0r�r5�_errorrr#r��_get_child_validatorru�_errors)rArtrY�
definitionr�r3s      r�_check_with_bulk_schemaz,SchemaValidatorMixin._check_with_bulk_schemaUsI���e�Y�'�'�
	#���1�1�1����)�-�-�e�4�4�4��.�A�E�E�e�L�L�J��!����E�#G�%�#O�P�P�P���"��
�(�E�*�+�+���.�<�=�=�
���D�)�8�8�8��F��-�-� ���(�.�.�
�
�	�
	�	�%�5�)�)�)�)���	<��K�K�	�)�*�*�*�*�*��!�0�4�4�U�;�;�;�;�;rc��t|t��rdSt|t��rG|�|dddiid���}||d���s|�|j��dSdSt|t��r<td�|D����s%|j|fz}|�|d	��dSdSdS)
Nr�r��listT�r�r@r-Fr�c3�@K�|]}t|t��V��dSrJ)r1rr�s  rr�z@SchemaValidatorMixin._check_with_dependencies.<locals>.<genexpr>�s,����>�>�1�z�!�X�.�.�>�>�>�>�>�>rz)All dependencies must be a hashable type.)	r1rr	r�r�r�rr��
document_path)rArtrYr3�paths     r�_check_with_dependenciesz-SchemaValidatorMixin._check_with_dependenciesus
���e�Y�'�'�
	O��D�
��w�
'�
'�	O��1�1�$�%���'7�8�"�2���I�
�9�U�e�4�4�4�
/����I�-�.�.�.�.�.�
/�
/�
��x�
(�
(�	O��>�>��>�>�>�>�>�
O��)�U�H�4�����D�"M�N�N�N�N�N�	O�	O�
O�
Orc�`�t|��D]\}}|�||f|���dSrJ)�	enumerater�)rArtrY�ir@s     r�_check_with_itemsz&SchemaValidatorMixin._check_with_items�sD��"�5�)�)�	=�	=�I�A�v��(�(�%���V�<�<�<�<�	=�	=rc���	|�||��}n#t$rYdSwxYwt|��t|jj��f}||jjvrdS|�|d|j���}||�|��d���|j	r|�
|j	��dS|jj�|��dS)Nr�Fr�)�&_handle_schema_reference_for_validatorrrr0r#r�r��root_allow_unknown�_expand_rules_set_refsr�r�r�)rArtrYr�r3s     r�_check_with_schemaz'SchemaValidatorMixin._check_with_schema�s��	��?�?��u�M�M�E�E���	�	�	��F�F�	�����e�$�$�l�4�3H�3V�&W�&W�X���D�)�8�8�8��F��-�-� ��T�=T�.�
�
�	�	�	�$�-�-�e�4�4��F�F�F�F���	<��K�K�	�)�*�*�*�*�*��!�0�4�4�U�;�;�;�;�;s��
'�'c�&�t|t��rt|f��nt|��}|t|jj��z
}|r>|�|d�d�|������dSdS)NzUnsupported types: {}z, )r1rr�r0�typesr�r9�join)rArtrY�invalid_constraintss    r�_check_with_typez%SchemaValidatorMixin._check_with_type�s���!+�E�9�!=�!=�M��U�H�
�
�
�3�u�:�:��#�c�$�*?�*E�&F�&F�F���	��K�K��.�5�5�d�i�i�@S�6T�6T�U�U�
�
�
�
�
�	�	rc��i}|���D]B\}}t|t��r#|jj�|��||<�=|||<�C|SrJ)rqr1rr0r�r5)rAr@�result�k�vs     rr�z+SchemaValidatorMixin._expand_rules_set_refs�sc�����L�L�N�N�	�	�D�A�q��!�Y�'�'�
� �1�D�H�H��K�K��q�	�	���q�	�	��
rc�@�t|t��s|S||jvrt�|j�|��|jj�|��}|�;|j|fz}|�	|d�
|����t�|S)NzSchema definition {} not found.)r1rr�rr�r0r4r5r�r�r9)rArtrYr�r�s     rr�z;SchemaValidatorMixin._handle_schema_reference_for_validator�s����%��+�+�	��L��D�*�*�*��L���"�"�5�)�)�)��*�:�>�>�u�E�E�
����%���0�D��K�K��?�F�F�u�M�M�N�N�N��L��rc���t|t��s"|�|tj��dS|�|d|jj���}|D]�}td|i��t|jj	��f}||jj
vr�;||d���|jr|�|j���j|jj
�|����dS)z2{'allowed': ('allof', 'anyof', 'noneof', 'oneof')}NFr�r�r�)
r1rr�r�BAD_TYPEr�r0�validation_rulesrr#r�r�r�)rArxrtrYr3�constraintsr�s       r�_validate_logicalz&SchemaValidatorMixin._validate_logical�s���%��*�*�	��K�K��v��/�/�/��F��-�-����(�9�.�
�
�	�!�	@�	@�K��h��4�5�5��T�2�@�A�A��E���-�<�<�<���I�k�U�3�3�3�3�� �
@����I�-�.�.�.�.��%�4�8�8��?�?�?�?�	@�	@r)rrrrrB�propertyr�r�r/r0r�r�r�r�r�r�r�r�r�r�s@rr"r"6s6���������
D�D�D�D�D�
�4�4��X�4��1�1��X�1��-�-��X�-��0�0��X�0�<�<�<�@O�O�O� =�=�=�<�<�<�&���������@�@�@�@�@�@�@rr"c�B�eZdZdZifd�Zd�Zd�Zd�Zd�Zd
d�Z	d	�Z
dS)�Registryz�
    A registry to store and retrieve schemas and parts of it by a name that can be used
    in validation schemas.

    :param definitions: Optional, initial definitions.
    :type definitions: any :term:`mapping`
    c�>�i|_|�|��dSrJ)�_storage�extend)rA�definitionss  rrBzRegistry.__init__�s!����
����K� � � � � rc�@�|�|��|j|<dS)aQ
        Register a definition to the registry. Existing definitions are replaced
        silently.

        :param name: The name which can be used as reference in a validation
                     schema.
        :type name: :class:`str`
        :param definition: The definition.
        :type definition: any :term:`mapping`
        N)�_expand_definitionr�)rA�namer�s   rr�zRegistry.add�s$��#�5�5�j�A�A��
�d���rc��|jS)z_
        Returns a :class:`dict` with all registered definitions mapped to their name.
        )r�rOs rr�zRegistry.all�s���}�rc�8�|j���dS)z&Purge all definitions in the registry.N)r��clearrOs rr�zRegistry.clear�s���
�������rc��t|�����D]\}}|�||���dS)a
        Add several definitions at once. Existing definitions are
        replaced silently.

        :param definitions: The names and definitions.
        :type definitions: a :term:`mapping` or an :term:`iterable` with
                           two-value :class:`tuple` s
        N)r6rqr�)rAr�r�r�s    rr�zRegistry.extend�sM��!%�[� 1� 1� 7� 7� 9� 9�	'�	'��D�*��H�H�T�:�&�&�&�&�	'�	'rNc�8�|j�||��S)z�
        Retrieve a definition from the registry.

        :param name: The reference that points to the definition.
        :type name: :class:`str`
        :param default: Return value if the reference isn't registered.
        )r�r5)rAr�r�s   rr5zRegistry.get	s���}� � ��w�/�/�/rc�F�|D]}|j�|d���dS)z�
        Unregister definitions from the registry.

        :param names: The names of the definitions that are to be
                      unregistered.
        N)r�r�)rA�namesr�s   r�removezRegistry.removes8���	*�	*�D��M���d�D�)�)�)�)�	*�	*rrJ)rrrrrBr�r�r�r�r5r�rrrr�r��s���������$&�!�!�!�!�B�B�B�������
'�
'�
'�0�0�0�0�*�*�*�*�*rr�c�$�eZdZed���ZdS)�SchemaRegistryc�6�t�|��SrJ�rr>�r(r�s  rr�z!SchemaRegistry._expand_definitions���&�&�z�2�2�2rN�rrrr�r�rrrr�r�s-�������3�3��[�3�3�3rr�c�$�eZdZed���ZdS)�RulesSetRegistryc�F�t�d|i��dSrXr�rs  rr�z#RulesSetRegistry._expand_definition%s���&�&��:��7�7��:�:rNrrrrrr$s-�������;�;��[�;�;�;rrN)�
__future__r�warningsr�cerberusr�cerberus.platformrrrr	r
r�cerberus.utilsrr
rrr7rrrr�r:�objectr"r�r�rr4r�rrr�<module>rs���&�&�&�&�&�&�����������������������������������������	�	�	�	�	�Y�	�	�	�	�	�	�	�	�)�	�	�	�y<�y<�y<�y<�y<�~�y<�y<�y<�x2�2�2�2�2�(�2�2�2�
�
�
�
�
�.�
�
�
�]@�]@�]@�]@�]@�6�]@�]@�]@�FB*�B*�B*�B*�B*�v�B*�B*�B*�J3�3�3�3�3�X�3�3�3�;�;�;�;�;�x�;�;�;�'5�n�&6�&6�8H�8H�8J�8J�#��#�#�#r

Hacked By AnonymousFox1.0, Coded By AnonymousFox