[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.117.155.118: ~ $
U

���`�G�@s�ddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZddl
mZmZmZmZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze�e�ZZdS)�)�absolute_import)�warn)�errors)�	_str_type�Callable�Hashable�Mapping�MutableMapping�Sequence)�get_Validator_class�validator_factory�mapping_hash�TypeDefinitionc@seZdZdS)�_AbortN)�__name__�
__module__�__qualname__�rr�@/opt/alt/python38/lib/python3.8/site-packages/cerberus/schema.pyrsrc@seZdZdZdS)�SchemaErrorz_
    Raised when the validation schema is missing, has the wrong format or contains
    errors.N)rrr�__doc__rrrrrsrcs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zedd��Zd+dd�Zdd �Zd!d"�Zed#d$��Zd%d&�Zd,d'd(�Zd)d*�Z�ZS)-�DefinitionSchemaz1A dict-subclass for caching of validated schemas.csXdt�krHtdt�atj��}|�tdtfd�tdt	fd�d��|t_t
t|��|�S)N�SchemaValidator�callabler�hashable)rr)
�globalsr�SchemaValidatorMixinr�
types_mapping�copy�updaterrr�superr�__new__)�cls�args�kwargsr��	__class__rrr!%s


��zDefinitionSchema.__new__cCs�t|t��std��||_t|t�r2|j�||�}t|t�snzt|�}Wn$t	k
rlt
tj�
|���YnXt|�|_td|jtj||d�|_|�|�}|�|�||_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_unknownZ
error_handler�
target_schema�target_validator)�
isinstancer�RuntimeError�	validatorr�schema_registry�getr�dict�	Exceptionrr�SCHEMA_ERROR_DEFINITION_TYPE�format�SchemaValidationSchema�validation_schemarZSchemaErrorHandler�schema_validator�expand�validate�schema)�selfr,r8rrr�__init__4s*


�

zDefinitionSchema.__init__c
Csf|j��}z
||=WnDtk
r4td|��Yn.tk
rX}z|�W5d}~XYn
X|j|=dS)Nz Schema has no field '%s' defined)r8r�
ValueErrorrr0)r9�key�_new_schema�errr�__delitem__Us

zDefinitionSchema.__delitem__cCs
|j|S�N)r8)r9�itemrrr�__getitem__`szDefinitionSchema.__getitem__cCs
t|j�Sr@)�iterr8�r9rrr�__iter__cszDefinitionSchema.__iter__cCs
t|j�Sr@)�lenr8rDrrr�__len__fszDefinitionSchema.__len__cCst|�Sr@)�strrDrrr�__repr__iszDefinitionSchema.__repr__cCs.|�d|i�d}|�||i�||j|<dS�Nr)r6r7r8)r9r<�valuerrr�__setitem__lszDefinitionSchema.__setitem__cCst|d�rt|j�SdSdS)Nr8zNo schema data is set yet.)�hasattrrHr8rDrrr�__str__qs

zDefinitionSchema.__str__cCs|�|j|j���Sr@)r&r,r8rrDrrrrwszDefinitionSchema.copycCs<z|�|�}|�|�}Wntk
r,YnX|�|�}|Sr@)�_expand_logical_shortcuts�_expand_subschemasr0�_rename_deprecated_rulenames)r"r8rrrr6zs

zDefinitionSchema.expandcszdd��|��D]d\}}�fdd�|D�D]H}|�dd�\}}|�|gi�||D]}||�||i�qT||=q*q|S)z�
        Expand agglutinated rules in a definition-schema.

        :param schema: The schema-definition to expand.
        :return: The expanded schema-definition.
        cSst|t�o|�d�S)N)Zallof_Zanyof_Znoneof_Zoneof_)r*r�
startswith)�xrrr�
is_of_rule�s�z>DefinitionSchema._expand_logical_shortcuts.<locals>.is_of_rulecsg|]}�|�r|�qSrr��.0rS�rTrr�
<listcomp>�sz>DefinitionSchema._expand_logical_shortcuts.<locals>.<listcomp>�_�)�items�splitr�append)r"r8�field�rulesZof_rule�operator�rulerKrrWrrO�s	
z*DefinitionSchema._expand_logical_shortcutsc	s��fdd�}��fdd�}�D]�|�s,nD|�rN|���d���d<n"|�d��di�d��d<dD]2}|��krt|�d��|i�d��|<qtdD]^}|��kr�t��|t�s�q�g}��|D]}|�|�d|i�d�q�|��|<q�q �S)	Ncst��t�od��kS)Nr8�r*rr�r^r8rr�has_schema_rule�sz<DefinitionSchema._expand_subschemas.<locals>.has_schema_rulecs<z tdd���d��D��WStk
r6YdSXdS)zw
            Tries to determine heuristically if the schema-constraints are aimed to
            mappings.
            css|]}t|t�VqdSr@rbrUrrr�	<genexpr>�szRDefinitionSchema._expand_subschemas.<locals>.has_mapping_schema.<locals>.<genexpr>r8FN)�all�values�	TypeErrorrrcrr�has_mapping_schema�s�
z?DefinitionSchema._expand_subschemas.<locals>.has_mapping_schemar8r)�	keysrules�valuesrules�	keyschema�valueschema)ZallofZanyofr[ZnoneofZoneof)r6r*r
r])r"r8rdriraZnew_rules_definitionrArrcrrP�s("$z#DefinitionSchema._expand_subschemasNcCs|j�||�Sr@)r8r.)r9rA�defaultrrrr.�szDefinitionSchema.getcCs
|j��Sr@)r8r[rDrrrr[�szDefinitionSchema.itemsc
Cs�z,|�|�}|j��}|�|�|�|�WnHtk
rPttj�	|���Yn,t
k
rt}z|�W5d}~XYnX||_dSr@)r6r8rrr7r;rrr1r2r0)r9r8r=r>rrrr�s


zDefinitionSchema.updatecCs�|��D]r\}}t|t�rqdD]X\}}||kr2q ||krBtd��tdj||d�t�||||||<||�|�q q|S)N))rlrj)r,Z
check_with)rmrkzTThe 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)r[r*rHr+rr2�DeprecationWarning�pop)r8r^r_rorprrrrQ�s(
���z-DefinitionSchema._rename_deprecated_rulenamescCst|j�|_dSr@)r3r,r4rDrrr�regenerate_validation_schema�sz-DefinitionSchema.regenerate_validation_schemacCsJ|dkr|j}t|�t|jj�f}||jjkrF|�|�|jj�|�dS)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)r8r
r,r�_valid_schemas�	_validate�add)r9r8�_hashrrrr7�s	
zDefinitionSchema.validatecCs�t|t�r|jj�||�}i}|��D]R\}}t|t�rJt�||�||<q&i}|��D]\}}|||�dd�<qV|||<q&|j|dd�s�t	|jj
��dS)N� rYF�Z	normalize)r*rr,r-r.r[�rules_set_registry�replacer5rr)r9r8Ztest_schemar^r_Z
test_rulesraZ
constraintrrrrus


zDefinitionSchema._validate)N)N)rrrrr!r:r?rBrErGrIrLrNr�classmethodr6rOrPr.r[r�staticmethodrQrsr7ru�
__classcell__rrr%rr"s2!


'

 
rc@s(eZdZifdd�Zdd�Zdd�ZdS)�UnvalidatedSchemacCst|t�st|�}||_dSr@)r*rr/r8�r9r8rrrr:!s
zUnvalidatedSchema.__init__cCsdSr@rr�rrrr7&szUnvalidatedSchema.validatecCs|�|j���Sr@)r&r8rrDrrrr)szUnvalidatedSchema.copyN)rrrr:r7rrrrrr src@seZdZdd�ZdS)r3cCsd|jdd�|_dS)NFr/)r'r8�type)r_r8)r9r,rrrr:0s�zSchemaValidationSchema.__init__N)rrrr:rrrrr3/sr3cs�eZdZdZ�fdd�Zedd��Zedd��Zedd	��Zed
d��Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS)rzi
    This validator mixin provides mechanics to validate schemas passed to a Cerberus
    validator.
    cs2|�dt��|�dt��tt|�j||�dS)N�known_rules_set_refs�known_schema_refs)�
setdefault�setr rr:)r9r#r$r%rrr:>szSchemaValidatorMixin.__init__cCs
|jdS)z7The encountered references to rules set registry items.r��Z_configrDrrrr�Csz)SchemaValidatorMixin.known_rules_set_refscCs
|jdS)z4The encountered references to schema registry items.r�r�rDrrrr�Hsz&SchemaValidatorMixin.known_schema_refscCs
|jdS)z#The schema that is being validated.r(r�rDrrrr(Msz"SchemaValidatorMixin.target_schemacCs
|jdS)z.The validator whose schema is being validated.r)r�rDrrrr)Rsz%SchemaValidatorMixin.target_validatorcCs�t|t�rR||jkrdS|j�|�|jj�|�}|dkrN|�|d|�dS|}td|i�t|jj	�f}||jj
krzdS|j|d|jjd�}||dd�|j
r�|�|j
�n|jj
�|�dS)Nz"Rules set definition %s not found.�turingF��document_crumbr'r8ry)r*rr�rvr)rzr.�_errorr
rrt�_get_child_validatorr_�_errors)r9r^rK�
definitionrwr,rrr�_check_with_bulk_schemaWs.



��z,SchemaValidatorMixin._check_with_bulk_schemacCs�t|t�rnpt|t�rH|j|dddiidd�}||dd�s||�|j�n4t|t�r|tdd	�|D��s||j|f}|�|d
�dS)Nrkr��listT�r�r8r'Frycss|]}t|t�VqdSr@)r*rrUrrrre�sz@SchemaValidatorMixin._check_with_dependencies.<locals>.<genexpr>z)All dependencies must be a hashable type.)	r*rrr�r�r�r
rf�
document_path)r9r^rKr,�pathrrr�_check_with_dependenciesws


�
z-SchemaValidatorMixin._check_with_dependenciescCs&t|�D]\}}|�||f|�qdSr@)�	enumerater�)r9r^rK�ir8rrr�_check_with_items�sz&SchemaValidatorMixin._check_with_itemscCs�z|�||�}Wntk
r&YdSXt|�t|jj�f}||jjkrLdS|j|d|jd�}||�|�dd�|j	r�|�
|j	�n|jj�|�dS)Nr�Fry)�&_handle_schema_reference_for_validatorrr
r)rrtr�Zroot_allow_unknown�_expand_rules_set_refsr�r�rv)r9r^rKrwr,rrr�_check_with_schema�s �z'SchemaValidatorMixin._check_with_schemacCsLt|t�rt|f�nt|�}|t|jj�}|rH|�|d�d�|���dS)NzUnsupported types: {}z, )r*rr�r)�typesr�r2�join)r9r^rKZinvalid_constraintsrrr�_check_with_type�s�z%SchemaValidatorMixin._check_with_typecCs@i}|��D].\}}t|t�r2|jj�|�||<q|||<q|Sr@)r[r*rr)rzr.)r9r8�result�k�vrrrr��s

z+SchemaValidatorMixin._expand_rules_set_refscCsdt|t�s|S||jkrt�|j�|�|jj�|�}|dkr`|j|f}|�	|d�
|��t�|S)NzSchema definition {} not found.)r*rr�rrvr)r-r.r�r�r2)r9r^rKr�r�rrrr��s

z;SchemaValidatorMixin._handle_schema_reference_for_validatorcCs�t|t�s|�|tj�dS|j|d|jjd�}|D]X}td|i�t|jj	�f}||jj
kr^q4||dd�|jr~|�|j�q4|jj
�|�q4dS)z2{'allowed': ('allof', 'anyof', 'noneof', 'oneof')}NFr�r�ry)
r*r
r�rZBAD_TYPEr�r)Zvalidation_rulesr
rrtr�rv)r9rar^rKr,Zconstraintsrwrrr�_validate_logical�s$
�

�z&SchemaValidatorMixin._validate_logical)rrrrr:�propertyr�r�r(r)r�r�r�r�r�r�r�r�r~rrr%rr8s$



 	rc@sNeZdZdZifdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	dd�Z
dS)�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`
    cCsi|_|�|�dSr@)�_storage�extend)r9�definitionsrrrr:�szRegistry.__init__cCs|�|�|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�)r9�namer�rrrrv�szRegistry.addcCs|jS)z_
        Returns a :class:`dict` with all registered definitions mapped to their name.
        )r�rDrrrrf�szRegistry.allcCs|j��dS)z&Purge all definitions in the registry.N)r��clearrDrrrr��szRegistry.clearcCs&t|���D]\}}|�||�q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)r/r[rv)r9r�r�r�rrrr��s	zRegistry.extendNcCs|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�r.)r9r�rnrrrr.szRegistry.getcGs|D]}|j�|d�qdS)z�
        Unregister definitions from the registry.

        :param names: The names of the definitions that are to be
                      unregistered.
        N)r�rr)r9�namesr�rrr�removeszRegistry.remove)N)rrrrr:rvrfr�r�r.r�rrrrr��s


r�c@seZdZedd��ZdS)�SchemaRegistrycCs
t�|�Sr@�rr6�r"r�rrrr�!sz!SchemaRegistry._expand_definitionN�rrrr|r�rrrrr� sr�c@seZdZedd��ZdS)�RulesSetRegistrycCst�d|i�dSrJr�r�rrrr�'sz#RulesSetRegistry._expand_definitionNr�rrrrr�&sr�N)Z
__future__r�warningsrZcerberusrZcerberus.platformrrrrr	r
Zcerberus.utilsrrr
rr0rrrrr3�objectrr�r�r�r-rzrrrr�<module>s" 	$E

Filemanager

Name Type Size Permission Actions
__init__.cpython-38.opt-1.pyc File 826 B 0644
__init__.cpython-38.pyc File 826 B 0644
errors.cpython-38.opt-1.pyc File 20.44 KB 0644
errors.cpython-38.pyc File 20.44 KB 0644
platform.cpython-38.opt-1.pyc File 793 B 0644
platform.cpython-38.pyc File 793 B 0644
schema.cpython-38.opt-1.pyc File 17.55 KB 0644
schema.cpython-38.pyc File 17.55 KB 0644
utils.cpython-38.opt-1.pyc File 3.76 KB 0644
utils.cpython-38.pyc File 3.76 KB 0644
validator.cpython-38.opt-1.pyc File 50.99 KB 0644
validator.cpython-38.pyc File 50.99 KB 0644