Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib/python3.5/site-packages/jsonschema/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/jsonschema/__pycache__/exceptions.cpython-35.pyc



�$�]5�@s�ddlmZmZddlZddlZddlZddlZddlmZddl	m
Z
mZeddg�Z
e�Zej�ZGdd�de�ZGd	d
�d
e�ZGdd�de�Zejd
d�Gdd�de��ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze
edd�Ze�Zedd�ZdS)�)�defaultdict�dequeN)�_utils)�PY3�	iteritemsZanyOf�oneOfcs�eZdZefdfeeefd�fdd�	Zdd�Zdd�Zer`eZndd	�Ze	d
d��Z
edd
��Zedd��Z
dd�Zdd�Z�S)�_ErrorNcs�tt|�j|||||||||	|
�
||_t|�|_|_t|	�|_|_t	|�|_
||_|_||_
||_||_||_|
|_x|D]}||_q�WdS)N)�superr�__init__�messager�path�
relative_path�schema_path�relative_schema_path�list�context�cause�	__cause__�	validator�validator_value�instance�schema�parent)�selfrrrrrrrrrr�error)�	__class__��F/opt/alt/python35/lib/python3.5/site-packages/jsonschema/exceptions.pyr
s.
						
z_Error.__init__cCsd|jj|jfS)Nz<%s: %r>)r�__name__r)rrrr�__repr__:sz_Error.__repr__c
Cs�|j|j|j|jf}tdd�|D��r>|jStj|jdd�}tj|jdd�}|jtj	dj
��|j|jtj
t|j�dd��tj|�|jtj
|j�tj|�fS)Ncss|]}|tkVqdS)N)�_unset)�.0�mrrr�	<genexpr>Asz%_Error.__unicode__.<locals>.<genexpr>�width�Hzl

            Failed validating %r in %s%s:
            %s

            On %s%s:
            %s
            ����)rrrr�anyr�pprint�pformat�textwrap�dedent�rstrip�!_word_for_schema_in_error_messagerZformat_as_indexrr�indent�#_word_for_instance_in_error_messager
)rZessential_for_verbose�pschema�	pinstancerrr�__unicode__=sz_Error.__unicode__cCst|�jd�S)Nzutf-8)�unicode�encode)rrrr�__str__[sz_Error.__str__cCs||j��S)N)�	_contents)�cls�otherrrr�create_from^sz_Error.create_fromcCsE|j}|dkr|jSt|j�}|jt|j��|S)N)rr
r�
extendleft�reversed�
absolute_path)rrrrrrr=bs	z_Error.absolute_pathcCsE|j}|dkr|jSt|j�}|jt|j��|S)N)rrrr;r<�absolute_schema_path)rrrrrrr>ls	z_Error.absolute_schema_pathcKsFx?t|�D]1\}}t||�tkr
t|||�q
WdS)N)r�getattrr �setattr)r�kwargs�k�vrrr�_setvsz_Error._setc
s#d
}t�fdd�|D��S)Nrrrrrrrrrrc3s$|]}|t�|�fVqdS)N)r?)r!�attr)rrrr#�sz#_Error._contents.<locals>.<genexpr>)
rrrrrrrrrr)�dict)r�attrsr)rrr7{sz_Error._contents)r�
__module__�__qualname__r r
rr3rr6�classmethodr:�propertyr=r>rDr7rr)rrrs&	

rc@seZdZdZdZdS)�ValidationErrorrrN)rrHrIr.r0rrrrrL�srLc@seZdZdZdZdS)�SchemaErrorZ
metaschemarN)rrHrIr.r0rrrrrM�srM�hashTc@s(eZdZej�Zdd�ZdS)�RefResolutionErrorcCs
t|j�S)N)�str�_cause)rrrrr6�szRefResolutionError.__str__N)rrHrIrEZibrQr6rrrrrO�srOc@sCeZdZdd�Zdd�Zer3eZndd�ZdS)�UndefinedTypeCheckcCs
||_dS)N)�type)rrSrrrr
�szUndefinedTypeCheck.__init__cCsd|jS)Nz'Type %r is unknown to this type checker)rS)rrrrr3�szUndefinedTypeCheck.__unicode__cCst|�jd�S)Nzutf-8)r4r5)rrrrr6�szUndefinedTypeCheck.__str__N)rrHrIr
r3rr6rrrrrR�s
	rRc@sCeZdZdd�Zdd�Zer3eZndd�ZdS)�UnknownTypecCs||_||_||_dS)N)rSrr)rrSrrrrrr
�s		zUnknownType.__init__cCsetj|jdd�}tj|jdd�}tjdj��|jtj	|�tj	|�fS)Nr$r%z�
            Unknown type %r for validator with schema:
            %s

            While checking instance:
            %s
            )
r)r*rrr+r,r-rSrr/)rr1r2rrrr3�s
zUnknownType.__unicode__cCst|�jd�S)Nzutf-8)r4r5)rrrrr6�szUnknownType.__str__N)rrHrIr
r3rr6rrrrrT�s
	rTcsLeZdZd�fdd�Zdd�Zer<eZndd�Z�S)�FormatErrorNcs6tt|�j||�||_||_|_dS)N)r	rUr
rrr)rrr)rrrr
�s	zFormatError.__init__cCs|jS)N)r)rrrrr3�szFormatError.__unicode__cCs|jjd�S)Nzutf-8)rr5)rrrrr6�szFormatError.__str__)rrHrIr
r3rr6rr)rrrU�s
	rUc@s�eZdZdZeZfdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Ze
dd��ZdS)�	ErrorTreezG
    ErrorTrees make it easier to check which validations failed.

    cCspi|_t|j�|_xN|D]F}|}x|jD]}||}q8W||j|j<|j|_q"WdS)N)�errorsrrr7rrr�	_instance)rrWrZ	container�elementrrrr
�s	
zErrorTree.__init__cCs
||jkS)zD
        Check whether ``instance[index]`` has any errors.

        )r7)r�indexrrr�__contains__�szErrorTree.__contains__cCs1|jtk	r&||kr&|j||j|S)a]
        Retrieve the child tree one level down at the given ``index``.

        If the index is not in the instance that this tree corresponds to and
        is not known by this tree, whatever error would be raised by
        ``instance.__getitem__`` will be propagated (usually this is some
        subclass of `exceptions.LookupError`.

        )rXr r7)rrZrrr�__getitem__�szErrorTree.__getitem__cCs||j|<dS)N)r7)rrZ�valuerrr�__setitem__�szErrorTree.__setitem__cCs
t|j�S)zZ
        Iterate (non-recursively) over the indices in the instance with errors.

        )�iterr7)rrrr�__iter__�szErrorTree.__iter__cCs|jS)z*
        Same as `total_errors`.

        )�total_errors)rrrr�__len__szErrorTree.__len__cCsd|jjt|�fS)Nz<%s (%s total errors)>)rr�len)rrrrrszErrorTree.__repr__cCs3tdd�t|j�D��}t|j�|S)zU
        The total number of errors in the entire tree, including children.

        css!|]\}}t|�VqdS)N)rc)r!�_Ztreerrrr#sz)ErrorTree.total_errors.<locals>.<genexpr>)�sumrr7rcrW)rZchild_errorsrrrras"zErrorTree.total_errorsN)rrHrI�__doc__r rXr
r[r\r^r`rbrrKrarrrrrV�srVcs��fdd�}|S)Ncs,|j}t|j�|�k|�kfS)N)rrcr)rr)�strong�weakrr�	relevances	zby_relevance.<locals>.relevancer)rhrgrir)rgrhr�by_relevancesrjcCsut|�}t|d�}|dkr+dSttj|g|�d|�}x"|jrpt|jd|�}qOW|S)N�key)r_�next�max�	itertools�chainr�min)rWrk�bestrrr�
best_match#s!rr)�collectionsrrrnr)r+rEZ
jsonschemarZjsonschema.compatrr�	frozensetZWEAK_MATCHESZSTRONG_MATCHESZUnsetr �	ExceptionrrLrM�srOrRrTrU�objectrVrjrirrrrrr�<module>s*	qL