[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.117.73.72: ~ $


L�X�K�@s�dZddlmZddlmZmZmZddlmZmZddl	m
Z
ddlmZddl
mZddlmZmZed	d
�Zedd�Zedd�Zd
Zedd�Zedd�Zedd�Zedd�Zedd�Zedd�ZdZedd�Zedd�Zedd�Zedd�Zed d!�Zed"d#�Z ed$d%�Z!ed&d'�Z"ed(d)�Z#ed*d+�Z$ed,d-�Z%ed.d-�Z&ed/d0�Z'ed1d0�Z(ed2d�Z)ed3d4�Z*ed5d6�Z+ed7d8�Z,ed9d:�Z-ed;d�Z.ed<d�Z/ed=d�Z0ed>d?�Z1ed@dA�Z2edBd!�Z3edCd�Z4edDdE�Z5edFdG�Z6edHdI�Z7edJdK�Z8dLZ9dMZ:GdNdO�dOe;�Z<GdPdQ�dQe=�Z>GdRdS�dSe�Z?GdTdU�dUe?�Z@GdVdW�dWe@�ZAGdXdY�dYe@�ZBGdZd[�d[e;�ZCGd\d]�d]eC�ZDd^d_�ZEGd`da�daeC�ZFGdbdc�dceF�ZGdS)dz? This module contains the error-related constants and classes. �)�absolute_import)�defaultdict�
namedtuple�MutableMapping)�copy�deepcopy)�wraps)�pformat)�PYTHON_VERSION)�compare_paths_lt�quote_stringZcerberus_errorz
code, ruleN�zdocument is missing�Zrequired��Zdependencies��Zexcludes�!z''{0}' is not a document, must be a dict�"�empty�#Znullable�$�type�%�schema�&�items�'Z	minlength�(�	maxlength�A�regex�B�min�C�max�DZallowed�E�FZ	forbidden�G�`�aZcoerce�bZrename_handler�c�readonly�dZdefault_setter����Z	keyschema�Zvalueschema���Znoneof�Zoneof�Zanyof�Zallofz0schema definition for field '{0}' must be a dictzvalidation schema missingc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
e	dd��Ze	dd��Ze	dd��Z
e	dd��Ze	dd��ZdS)�ValidationErrorz< A simple class to store and query basic error information. cCsC||_||_||_||_||_||_||_dS)N)�
document_path�schema_path�code�rule�
constraint�value�info)�selfr<r=r>r?r@rArB�rD�
/errors.py�__init__^s							zValidationError.__init__cCst|�t|�kS)z< Assumes the errors relate to the same document and schema. )�hash)rC�otherrDrDrE�__eq__rszValidationError.__eq__cCs't|j�t|j�At|j�AS)z@ Expects that all other properties are transitively determined. )rGr<r=r>)rCrDrDrE�__hash__vszValidationError.__hash__cCs<|j|jkr%t|j|j�St|j|j�SdS)N)r<rr=)rCrHrDrDrE�__lt__{szValidationError.__lt__cCspdjd|jjdtt|��d|jd|jdt|j�dt|j	�dt|j
�d	|j�S)
Nz�{class_name} @ {memptr} ( document_path={document_path},schema_path={schema_path},code={code},constraint={constraint},value={value},info={info} )�
class_nameZmemptrr<r=r>r@rArB)�format�	__class__�__name__�hex�idr<r=r>rr@rArB)rCrDrDrE�__repr__�s			zValidationError.__repr__cCs|jr|jdSdS)zX
        A list that contains the individual errors of a bulk validation error.
        rN)�is_group_errorrB)rCrDrDrE�child_errors�szValidationError.child_errorscCsX|js
dStt�}x8|jD]-}|jt|j�}||j|�q#W|S)z� Dictionary with errors of an *of-rule mapped to the index of the
            definition it occurred in. Returns :obj:`None` if not applicable.
            N)�is_logic_errorr�listrTr=�len�append)rC�result�error�irDrDrE�definitions_errors�s	z"ValidationError.definitions_errorscCs|jr|jdSdSdS)z8 Field of the contextual mapping, possibly :obj:`None`. r
N���)r<)rCrDrDrE�field�s	zValidationError.fieldcCst|jtj@�S)z* ``True`` for errors of bulk validations. )�boolr>�ERROR_GROUP)rCrDrDrErS�szValidationError.is_group_errorcCst|jtjtj@�S)zV ``True`` for validation errors against different schemas with
            *of-rules. )r_r>�LOGICALr`)rCrDrDrErU�szValidationError.is_logic_errorcCst|jtj@�S)z$ ``True`` for normalization errors. )r_r>�
NORMALIZATION)rCrDrDrE�is_normalization_error�sz&ValidationError.is_normalization_errorN)rO�
__module__�__qualname__�__doc__rFrIrJrKrR�propertyrTr\r^rSrUrcrDrDrDrEr;\sr;c@s"eZdZdZdd�ZdS)�	ErrorListz� A list for :class:`~cerberus.errrors.ValidationError` instances that
        can be queried with the ``in`` keyword for a particular error code. cCs5x.dd�|D�D]}||jkrdSqWdS)Ncss|]}|jVqdS)N)r>)�.0�xrDrDrE�	<genexpr>�sz)ErrorList.__contains__.<locals>.<genexpr>TF)r>)rCZerror_definitionr>rDrDrE�__contains__�szErrorList.__contains__N)rOrdrerfrlrDrDrDrErh�srhc@s�eZdZdZdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zedd��Z
edd��Zdd�Zdd�ZdS) �
ErrorTreeNode�descendants�errors�parent_node�path�	tree_rootcCsN||_|jj|_|d|jjd�|_t�|_i|_dS)Nr
)rprr�depthrqrhrorn)rCrqrprDrDrErF�s
	zErrorTreeNode.__init__cCs|j|�|S)N)�add)rCrZrDrDrE�__add__�s
zErrorTreeNode.__add__cCs|j|=dS)N)rn)rC�keyrDrDrE�__delitem__�szErrorTreeNode.__delitem__cCs
t|j�S)N)�iterro)rCrDrDrE�__iter__�szErrorTreeNode.__iter__cCs|jj|�S)N)rn�get)rC�itemrDrDrE�__getitem__�szErrorTreeNode.__getitem__cCs
t|j�S)N)rWro)rCrDrDrE�__len__�szErrorTreeNode.__len__cCs||j|<dS)N)rn)rCrvrArDrDrE�__setitem__�szErrorTreeNode.__setitem__cCst|j�dt|j�S)N�,)�strrorn)rCrDrDrE�__str__�szErrorTreeNode.__str__cCs
t|j�S)N)rWrq)rCrDrDrErs�szErrorTreeNode.depthcCs
|jjS)N)rr�	tree_type)rCrDrDrEr��szErrorTreeNode.tree_typecCs�|j|�}||j}||jkr>t||�||<t|�|jdkr�||jj|�||jj�|jr�x1|j	D]}|j
|7_
q�Wn|||7<dS)Nr
)�	_path_of_rsrnrmrWrorX�sortrSrTrr)rCrZZ
error_pathrv�child_errorrDrDrErt�s
	zErrorTreeNode.addcCst||jd�S)N�_path)�getattrr�)rCrZrDrDrEr�szErrorTreeNode._path_of_N)zdescendantszerrorszparent_nodezpathz	tree_root)rOrdre�	__slots__rFrurwryr|r}r~r�rgrsr�rtr�rDrDrDrErm�srmcsOeZdZdZgdd�Z�fdd�Zdd�Zdd	�Z�S)
�	ErrorTreezs Base class for :class:`~cerberus.errors.DocumentErrorTree` and
        :class:`~cerberus.errors.SchemaErrorTree`. cCsOd|_||_f|_t�|_i|_x|D]}||7}q7WdS)N)rprrrqrhrorn)rCrorZrDrDrErFs				
zErrorTree.__init__csI|j|�s/|jj|�|jj�ntt|�j|�dS)zd Add an error to the tree.

        :param error: :class:`~cerberus.errors.ValidationError`
        N)r�rorXr��superr�rt)rCrZ)rNrDrErtsz
ErrorTree.addcCs-|j|�}|dk	r"|jSt�SdS)z� Returns all errors for a particular path.

        :param path: :class:`tuple` of :term:`hashable` s.
        :rtype: :class:`~cerberus.errors.ErrorList`
        N)�fetch_node_fromrorh)rCrq�noderDrDrE�fetch_errors_fromszErrorTree.fetch_errors_fromcCs2|}x%|D]}||}|dkr
Pq
W|S)z� Returns a node for a path.

        :param path: Tuple of :term:`hashable` s.
        :rtype: :class:`~cerberus.errors.ErrorTreeNode` or :obj:`None`
        NrD)rCrq�contextrvrDrDrEr�(s

zErrorTree.fetch_node_from)rOrdrerfrFrtr�r�rDrD)rNrEr�s
	r�c@seZdZdZdZdS)�DocumentErrorTreezr Implements a dict-like class to query errors by indexes following the
        structure of a validated document. ZdocumentN)rOrdrerfr�rDrDrDrEr�6sr�c@seZdZdZdZdS)�SchemaErrorTreezm Implements a dict-like class to query errors by indexes following the
        structure of the used schema. rN)rOrdrerfr�rDrDrDrEr�<sr�c@sveZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�BaseErrorHandlerzo Base class for all error handlers.
        Subclasses are identified as error-handlers with an instance-test. cOsdS)z' Optionally initialize a new instance. NrD)rC�args�kwargsrDrDrErFEszBaseErrorHandler.__init__cCs
t�dS)a$ Returns errors in a handler-specific format.

        :param errors: An object containing the errors.
        :type errors: :term:`iterable` of
                      :class:`~cerberus.errors.ValidationError` instances or a
                      :class:`~cerberus.Validator` instance
        N)�NotImplementedError)rCrorDrDrE�__call__IszBaseErrorHandler.__call__cCs
t�dS)z7 Be a superhero and implement an iterator over errors. N)r�)rCrDrDrErySszBaseErrorHandler.__iter__cCs
t�dS)z� Add an error to the errors' container object of a handler.

        :param error: The error to add.
        :type error: :class:`~cerberus.errors.ValidationError`
        N)r�)rCrZrDrDrErtWszBaseErrorHandler.addcCsdS)z� Optionally emits an error in the handler's format to a stream.
            Or light a LED, or even shut down a power plant.

        :param error: The error to emit.
        :type error: :class:`~cerberus.errors.ValidationError`
        NrD)rCrZrDrDrE�emit_szBaseErrorHandler.emitcCsdS)z� Gets called when a validation ends.

        :param validator: The calling validator.
        :type validator: :class:`~cerberus.Validator` NrD)rC�	validatorrDrDrE�endhszBaseErrorHandler.endcCs"x|D]}|j|�qWdS)z� Adds all errors to the handler's container object.

        :param errors: The errors to add.
        :type errors: :term:`iterable` of
                      :class:`~cerberus.errors.ValidationError` instances
        N)rt)rCrorZrDrDrE�extendos
zBaseErrorHandler.extendcCsdS)z� Gets called when a validation starts.

        :param validator: The calling validator.
        :type validator: :class:`~cerberus.Validator`
        NrD)rCr�rDrDrE�startyszBaseErrorHandler.startN)rOrdrerfrFr�ryrtr�r�r�r�rDrDrDrEr�Bs
	
r�c@s(eZdZdd�Zdd�ZdS)�ToyErrorHandlercOstd��dS)NzThis is not supposed to happen.)�RuntimeError)rCr�r�rDrDrEr��szToyErrorHandler.__call__cCsdS)NrD)rCrDrDrE�clear�szToyErrorHandler.clearN)rOrdrer�r�rDrDrDrEr��sr�cs2t���fdd��}tdkr.|S�S)z�Cerberus error messages expect regular binary strings.
    If unicode is used in a ValidationError message can't be printed.

    This decorator ensures that if legacy Python is used unicode
    strings are encoded before passing to a function.
    csdd�}t|�}||j�|_||j�|_||j�|_||j�|_||j�|_�||�S)NcSs t|t�r|jd�S|S)z1Helper encoding unicode strings into binary utf-8zutf-8)�
isinstance�unicode�encode)rArDrDrE�_encode�s
z0encode_unicode.<locals>.wrapped.<locals>._encode)rr<r=r@rArB)�objrZr�)�frDrE�wrapped�szencode_unicode.<locals>.wrappedr)rr
)r�r�rD)r�rE�encode_unicode�sr�cF@s�eZdZdZdddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d'd+d)d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d7d=d>d?d@dAdBdCdDi#ZdEdFdG�ZdEdHdI�ZdJdK�ZedLdM��Z	dNdO�Z
dPdQ�ZdRdS�ZdTdU�Z
dVdW�ZedXdY��ZdZd[�Zd\d]�ZdES)^�BasicErrorHandlerz3 Models cerberus' legacy. Returns a :class:`dict`. rz{0}r
zdocument is missingrzrequired fieldrz
unknown fieldrzfield '{0}' is requiredrz%depends on these values: {constraint}rz&{0} must not be present with '{field}'rz''{0}' is not a document, must be a dictrzempty values not allowedrznull value not allowedrzmust be of {constraint} typerzmust be of dict typerz0length of list should be {constraint}, it is {0}rzmin length is {constraint}rzmax length is {constraint}r z)value does not match regex '{constraint}'r"zmin value is {constraint}r$zmax value is {constraint}r&zunallowed value {value}r'zunallowed values {0}r(r)r+z&field '{field}' cannot be coerced: {0}r,z&field '{field}' cannot be renamed: {0}r-zfield is read-onlyr/z.default value for '{field}' cannot be set: {0}r1z'mapping doesn't validate subschema: {0}r2z.one or more sequence-items don't validate: {0}r3z2one or more keys of a mapping  don't validate: {0}r4z3one or more values in a mapping don't validate: {0}�r7z one or more definitions validater8z#none or more than one rule validater9zno definitions validater:z&one or more definitions don't validateNcCs|dkrin||_dS)N)�tree)rCr�rDrDrErF�szBasicErrorHandler.__init__cCs*|dk	r#|j�|j|�|jS)N)r�r��pretty_tree)rCrorDrDrEr��s

zBasicErrorHandler.__call__cCs
t|j�S)N)r	r�)rCrDrDrEr��szBasicErrorHandler.__str__cCsj|jr|j|�nM|jr2|j|�n4|j|jkrf|j|j|j|j	|��dS)N)
rU�insert_logic_errorrS�insert_group_errorr>�messages�insert_errorr<�format_messager^)rCrZrDrDrErt�s		zBasicErrorHandler.addcCs
i|_dS)N)r�)rCrDrDrEr��szBasicErrorHandler.clearcCs2|j|jj|jd|jd|d|j�S)Nr@r^rA)r�r>rMrBr@rA)rCr^rZrDrDrEr��sz BasicErrorHandler.format_messagecCs|d}t|�dkrn||jkrX|j|j�}|j|||g7<q|ig|j|<n�t|�dkr||jkr�ig|j|<|j|d}|r�|jdt|��}n|j�}|j|dd�|�|j|j�dS)z� Adds an error or sub-tree to :attr:tree.

        :param path: Path to the error.
        :type path: Tuple of strings and integers.
        :param node: An error message or a sub-tree.
        :type node: String or dictionary.
        rr
r�Nr])rWr��poprNrr��update)rCrqr�r^�subtree�newrDrDrEr��s
zBasicErrorHandler.insert_errorcCslxe|jD]Z}|jr)|j|�q
|jrB|j|�q
|j|j|j|j|��q
WdS)N)	rTrUr�rSr�r�r<r�r^)rCrZrDrDrEr�s		z$BasicErrorHandler.insert_group_errorcCs�|j|jf}|j}|j||j||��x�|jD]�}|j|}|s^qBd|j|f}xU|D]M}|jr�t�qx|jr�t�qx|j||f|j||��qxWqBWdS)Nz%s definition %s)	r<r?r^r�r�r\rUr�rS)rCrZrqr^r[rT�nodenamer�rDrDrEr�s	

				z$BasicErrorHandler.insert_logic_errorcCs5t|j�}x|D]}|j||�qW|S)N)rr��_purge_empty_dicts)rCZprettyr^rDrDrEr�*s
zBasicErrorHandler.pretty_treecCsG|d}|ds!|j�n"x|D]}|j||�q(WdS)Nr
r]r])r�r�)rCZ
error_listr�rvrDrDrEr�1s




z$BasicErrorHandler._purge_empty_dictscCs|j�dS)N)r�)rCr�rDrDrEr�9szBasicErrorHandler.start)rOrdrerfr�rFr�r�r�rtr�r�r�r�r�rgr�r�r�rDrDrDrEr��s`

r�c@s)eZdZejj�Zded<dS)�SchemaErrorHandlerzunknown rulerN)rOrdrer�r�rrDrDrDrEr�=sr�)HrfZ
__future__r�collectionsrrrrr�	functoolsr�pprintr	Zcerberus.platformr
Zcerberus.utilsrrZErrorDefinitionZCUSTOMZDOCUMENT_MISSINGZREQUIRED_FIELDZ
UNKNOWN_FIELDZDEPENDENCIES_FIELDZDEPENDENCIES_FIELD_VALUEZEXCLUDES_FIELDZDOCUMENT_FORMATZEMPTY_NOT_ALLOWEDZNOT_NULLABLEZBAD_TYPEZBAD_TYPE_FOR_SCHEMAZITEMS_LENGTHZ
MIN_LENGTHZ
MAX_LENGTHZREGEX_MISMATCHZ	MIN_VALUEZ	MAX_VALUEZUNALLOWED_VALUEZUNALLOWED_VALUESZFORBIDDEN_VALUEZFORBIDDEN_VALUESrbZCOERCION_FAILEDZRENAMING_FAILEDZREADONLY_FIELDZSETTING_DEFAULT_FAILEDr`ZMAPPING_SCHEMAZSEQUENCE_SCHEMAZ	KEYSCHEMAZVALUESCHEMAZ	BAD_ITEMSraZNONEOFZONEOFZANYOFZALLOFZSCHEMA_ERROR_DEFINITION_TYPEZSCHEMA_ERROR_MISSING�objectr;rVrhrmr�r�r�r�r�r�r�r�rDrDrDrE�<module>sz
c
<1@�

Filemanager

Name Type Size Permission Actions
__init__.cpython-35.opt-1.pyc File 704 B 0644
__init__.cpython-35.pyc File 704 B 0644
errors.cpython-35.opt-1.pyc File 20.06 KB 0644
errors.cpython-35.pyc File 20.06 KB 0644
platform.cpython-35.opt-1.pyc File 364 B 0644
platform.cpython-35.pyc File 364 B 0644
schema.cpython-35.opt-1.pyc File 16.08 KB 0644
schema.cpython-35.pyc File 16.08 KB 0644
utils.cpython-35.opt-1.pyc File 3.13 KB 0644
utils.cpython-35.pyc File 3.13 KB 0644
validator.cpython-35.opt-1.pyc File 49.72 KB 0644
validator.cpython-35.pyc File 49.72 KB 0644