U
    kufP  ã                   @  sö   d Z ddlmZ ddlmZmZ ddlZddlmZ erPddl	m
Z
 ddlmZ eG dd	„ d	eƒƒZeG d
d„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZejG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZdS )z
Errors, oh no!
é    )Úannotations)ÚTYPE_CHECKINGÚAnyN)Úfrozen)ÚResource)ÚURIc                   @  s8   e Zd ZU dZded< dddœdd„Zd	d
œdd„ZdS )ÚNoSuchResourcez»
    The given URI is not present in a registry.

    Unlike most exceptions, this class *is* intended to be publicly
    instantiable and *is* part of the public API of the package.
    r   ÚrefÚobjectÚbool©ÚotherÚreturnc                 C  s$   | j |j k	rtS t | ¡t |¡kS ©N©Ú	__class__ÚNotImplementedÚattrsÚastuple©Úselfr   © r   ú:/tmp/pip-unpacked-wheel-g5oy8ly_/referencing/exceptions.pyÚ__eq__   s    zNoSuchResource.__eq__Úint©r   c                 C  s   t t | ¡ƒS r   ©Úhashr   r   ©r   r   r   r   Ú__hash__"   s    zNoSuchResource.__hash__N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   r   r      s   
r   c                   @  s8   e Zd ZU dZded< dddœdd„Zd	d
œdd„ZdS )ÚNoInternalIDa  
    A resource has no internal ID, but one is needed.

    E.g. in modern JSON Schema drafts, this is the :kw:`$id` keyword.

    One might be needed if a resource was to-be added to a registry but no
    other URI is available, and the resource doesn't declare its canonical URI.
    úResource[Any]Úresourcer
   r   r   c                 C  s$   | j |j k	rtS t | ¡t |¡kS r   r   r   r   r   r   r   3   s    zNoInternalID.__eq__r   r   c                 C  s   t t | ¡ƒS r   r   r   r   r   r   r   8   s    zNoInternalID.__hash__Nr    r   r   r   r   r&   &   s   
	r&   c                   @  s8   e Zd ZU dZded< dddœdd„Zd	d
œdd„ZdS )ÚUnretrievablezO
    The given URI is not present in a registry, and retrieving it failed.
    r   r	   r
   r   r   c                 C  s$   | j |j k	rtS t | ¡t |¡kS r   r   r   r   r   r   r   D   s    zUnretrievable.__eq__r   r   c                 C  s   t t | ¡ƒS r   r   r   r   r   r   r   I   s    zUnretrievable.__hash__Nr    r   r   r   r   r)   <   s   
r)   c                   @  s8   e Zd ZU dZded< dddœdd„Zd	d
œdd„ZdS )ÚCannotDetermineSpecificationzÅ
    Attempting to detect the appropriate `Specification` failed.

    This happens if no discernible information is found in the contents of the
    new resource which would help identify it.
    r   Úcontentsr
   r   r   c                 C  s$   | j |j k	rtS t | ¡t |¡kS r   r   r   r   r   r   r   X   s    z#CannotDetermineSpecification.__eq__r   r   c                 C  s   t t | ¡ƒS r   r   r   r   r   r   r   ]   s    z%CannotDetermineSpecification.__hash__Nr    r   r   r   r   r*   M   s   
r*   c                   @  s8   e Zd ZU dZded< dddœdd„Zd	d
œdd„ZdS )ÚUnresolvablez'
    A reference was unresolvable.
    r   r	   r
   r   r   c                 C  s$   | j |j k	rtS t | ¡t |¡kS r   r   r   r   r   r   r   i   s    zUnresolvable.__eq__r   r   c                 C  s   t t | ¡ƒS r   r   r   r   r   r   r   n   s    zUnresolvable.__hash__Nr    r   r   r   r   r,   a   s   
r,   c                   @  s(   e Zd ZU dZded< ddœdd„ZdS )	ÚPointerToNowherezK
    A JSON Pointer leads to a part of a document that does not exist.
    r'   r(   Ústrr   c                 C  s*   | j ›d| jj›}| j dkr&|d7 }|S )Nú does not exist within ú/zœ. The pointer '/' is a valid JSON Pointer but it points to an empty string property ''. If you intended to point to the entire resource, you should use '#'.)r	   r(   r+   )r   Úmsgr   r   r   Ú__str__z   s    
ÿzPointerToNowhere.__str__N©r!   r"   r#   r$   r%   r2   r   r   r   r   r-   r   s   
r-   c                   @  s0   e Zd ZU dZded< ded< ddœdd„Zd	S )
ÚNoSuchAnchorz@
    An anchor does not exist within a particular resource.
    r'   r(   r.   Úanchorr   c                 C  s   | j ›d| jj›S )Nr/   )r5   r(   r+   r   r   r   r   r2   Ž   s    ÿzNoSuchAnchor.__str__Nr3   r   r   r   r   r4   …   s   
r4   c                   @  s0   e Zd ZU dZded< ded< ddœdd„Zd	S )
ÚInvalidAnchorzu
    An anchor which could never exist in a resource was dereferenced.

    It is somehow syntactically invalid.
    r'   r(   r.   r5   r   c                 C  s   d| j › d| j › dS )Nz'#zo' is not a valid anchor, neither as a plain name anchor nor as a JSON Pointer. You may have intended to use '#/zD', as the slash is required *before each segment* of a JSON pointer.)r5   r   r   r   r   r2   Ÿ   s    ÿzInvalidAnchor.__str__Nr3   r   r   r   r   r6   ”   s   
r6   )r$   Ú
__future__r   Útypingr   r   r   Zreferencing._attrsr   Zreferencingr   Zreferencing.typingr   ÚKeyErrorr   Ú	Exceptionr&   r)   r*   r,   r-   r4   r6   r   r   r   r   Ú<module>   s.   