o
    g8                     @  s  U d dl mZ d dlmZ d dlmZmZ d dlmZ d dlZd dl	Z	d dl
Z
d dlZd dlmZ e
jegef Ze
jdedZe
je
je e
je
je d	f f Ze	d
e	jZG dd dZe Ze Ze Ze Z e Z!e Z"e#eeee e!e"dZ$de%d< 								dedfddZ&e&dde&dddgddZ'e&ddddddej(ddgd d!Z)e&d"ej(d#dgd$d%Z*ee+ d d&l,m-Z- e&d'd(d(d(d(d(ddgd)d*Z.W d   n1 sw   Y  ee+ d dl/Z/e&d+d+d+e/j0e1fd,dgd-d.Z2W d   n	1 sw   Y  zd dl3Z3W n= e+yO   ee+& d d/l4m5Z5 e&d0ddgd1d2Z6e&d3d3d3d3e7d4dgd5d6Z8W d   n	1 sHw   Y  Y n4w e&d7d7d7e7d,dgd8d9Z9e&d:d:d:e7d,dgd;d<Z:e&d0e7d#dgd=d2Z6e&d3d3d3d3e7d4dgd>d6Z8ee+$ d d?l;m<Z< e&d@ddgdAdBZ=e&dCdCdCdDdgdEdFZ>W d   n	1 sw   Y  e&dGe	j?d#dgdHdIZ@e&dJdJdJdJe7dKdgdLdMZAe&dCe7dNdgdOdPZBee+ d dlCZCe&dQe7eDfdNdgdRdSZEW d   n	1 sw   Y  ee+) d dlFZFe&dTdTdTdTeFjGd4dgdUdVZHe&dWdWdWeFjGd,dgdXdYZIW d   n	1 s0w   Y  ee+ d dlJZJe&dZdZdZdZd[dgd\d]ZKW d   n	1 sVw   Y  ee+ d dlLZLe&d^d^eLjMd_dgd`daZNW d   n	1 s|w   Y  e&dbdbe7d_dgdcddZOdS )h    )annotations)suppress)datedatetime)UUIDN)FormatError_F)bound.z^\d{4}-\d{2}-\d{2}$c                   @  sx   e Zd ZU dZi Zded< d d!ddZd	d
 Z	d"d#ddZe		d"d#ddZ
e		d"d#ddZd$ddZd%ddZdS )&FormatCheckeraz  
    A ``format`` property checker.

    JSON Schema does not mandate that the ``format`` property actually do any
    validation. If validation is desired however, instances of this class can
    be hooked into validators to enable format validation.

    `FormatChecker` objects always return ``True`` when asked about
    formats that they do not know how to validate.

    To add a check for a custom format use the `FormatChecker.checks`
    decorator.

    Arguments:

        formats:

            The known formats to validate. This argument can be used to
            limit which formats will be used during validation.

    z3dict[str, tuple[_FormatCheckCallable, _RaisesType]]checkersNformatstyping.Iterable[str] | Nonec                   s*   |d u r	 j  } fdd|D  _ d S )Nc                   s   i | ]}| j | qS  r   ).0kselfr   N/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/jsonschema/_format.py
<dictcomp>6   s    z*FormatChecker.__init__.<locals>.<dictcomp>)r   keys)r   r   r   r   r   __init__3   s   
zFormatChecker.__init__c                 C  s   dt | j dS )Nz<FormatChecker checkers=>)sortedr   r   r   r   r   __repr__8   s   zFormatChecker.__repr__r   formatstrraises_RaisesTypereturntyping.Callable[[_F], _F]c                   s   d fdd}|S )a  
        Register a decorated function as validating a new format.

        Arguments:

            format:

                The format that the decorated function will check.

            raises:

                The exception(s) raised by the decorated function when an
                invalid instance is found.

                The exception object will be accessible as the
                `jsonschema.exceptions.ValidationError.cause` attribute of the
                resulting validation error.

        funcr   r   c                   s   | fj  < | S Nr   r!   r   r   r   r   r   _checksR      z%FormatChecker.checks.<locals>._checksNr!   r   r   r   r   )r   r   r   r%   r   r$   r   checks;   s   zFormatChecker.checksc                 C  s   t jdtdd | j||dS )NzoFormatChecker.cls_checks is deprecated. Call FormatChecker.checks on a specific FormatChecker instance instead.   )
stacklevel)r   r   )warningswarnDeprecationWarning_cls_checksclsr   r   r   r   r   
cls_checksX   s   	zFormatChecker.cls_checksc                   s   d fdd}|S )Nr!   r   r   c                   s   | f j < | S r"   r   r#   r/   r   r   r%   k   r&   z*FormatChecker._cls_checks.<locals>._checksr'   r   )r0   r   r   r%   r   r/   r   r.   g   s   zFormatChecker._cls_checksinstanceobjectNonec              
   C  sx   || j vrdS | j | \}}d\}}z||}W n |y, } z|}W Y d}~nd}~ww |s:t|d||ddS )a  
        Check whether the instance conforms to the given format.

        Arguments:

            instance (*any primitive type*, i.e. str, number, bool):

                The instance to check

            format:

                The format that instance should conform to

        Raises:

            FormatError:

                if the instance does not conform to ``format``

        N)NNz
 is not a )cause)r   r   )r   r2   r   r!   r   resultr5   er   r   r   checkq   s   
zFormatChecker.checkboolc                 C  s(   z	|  || W dS  ty   Y dS w )aW  
        Check whether the instance conforms to the given format.

        Arguments:

            instance (*any primitive type*, i.e. str, number, bool):

                The instance to check

            format:

                The format that instance should conform to

        Returns:

            bool: whether it conformed

        FT)r8   r   )r   r2   r   r   r   r   conforms   s   zFormatChecker.conformsr"   )r   r   )r   )r   r   r   r   r   r    )r2   r3   r   r   r   r4   )r2   r3   r   r   r   r9   )__name__
__module____qualname____doc__r   __annotations__r   r   r(   classmethodr1   r.   r8   r:   r   r   r   r   r
      s    
 

	!r
   )draft3draft4draft6draft7draft201909draft202012zdict[str, FormatChecker]_draft_checkersr   r   r    c           	        sN   p| p| p| p|  p|  p| d fdd}|S )Nr!   r   r   c                   s   rt d | } rt d | } r$t d | } r0t d | }  r<t d  | } rHt d | } tpU pUpUpUpU|  | S )NrA   rB   rC   rD   rE   rF   )rG   r(   r
   r.   r#   rE   rF   rA   rB   rC   rD   r   r   r   wrap   s.   z_checks_drafts.<locals>.wrapr'   r   )	namerA   rB   rC   rD   rE   rF   r   rI   r   rH   r   _checks_drafts   s   
rK   z	idn-email)rJ   emailr2   r3   r9   c                 C  s   t | tsdS d| v S )NT@)
isinstancer   r2   r   r   r   is_email   s   
rP   z
ip-addressipv4)rA   rB   rC   rD   rE   rF   r   c                 C     t | tsdS tt| S NT)rN   r   r9   	ipaddressIPv4AddressrO   r   r   r   is_ipv4   s   

rV   ipv6)rJ   r   c                 C  s&   t | tsdS t| }t|dd S )NTscope_id )rN   r   rT   IPv6Addressgetattr)r2   addressr   r   r   is_ipv6  s   

r]   )FQDNz	host-namehostnamec                 C  s   t | tsdS t| ddjS )NT   )
min_labels)rN   r   r^   is_validrO   r   r   r   is_host_name  s   
	rc   zidn-hostname)rD   rE   rF   r   c                 C  s   t | tsdS t|  dS rS   )rN   r   idnaencoderO   r   r   r   is_idn_host_name   s   

rf   )validate_rfc3986uric                 C     t | tsdS t| ddS NTURIrulerN   r   rg   rO   r   r   r   is_uri3     
ro   zuri-reference)rC   rD   rE   rF   r   c                 C  ri   NTURI_referencerl   rn   rO   r   r   r   is_uri_reference9  s   
rs   iric                 C     t | tsdS tj| ddS )NTIRIrl   rN   r   rfc3987parserO   r   r   r   is_iriG     
rz   ziri-referencec                 C  ru   )NTIRI_referencerl   rw   rO   r   r   r   is_iri_referenceR  r{   r}   c                 C  ru   rj   rw   rO   r   r   r   ro   ]     
c                 C  ru   rq   rw   rO   r   r   r   rs   c     
)validate_rfc3339z	date-timec                 C  s   t | tsdS t|  S rS   )rN   r   r   upperrO   r   r   r   is_datetimes  rp   r   time)rD   rE   rF   c                 C  s   t | tsdS td|  S )NTz1970-01-01T)rN   r   r   rO   r   r   r   is_timey  s   
r   regexc                 C  rR   rS   )rN   r   r9   recompilerO   r   r   r   is_regex  r~   r   r   )rA   rD   rE   rF   r   c                 C  s&   t | tsdS tt| ot| S rS   )rN   r   r9   _RE_DATE	fullmatchr   fromisoformatrO   r   r   r   is_date  s   
r   )rA   r   c                 C  s   t | tsdS tt| dS )NTz%H:%M:%S)rN   r   r9   r   strptimerO   r   r   r   is_draft3_time  s   
r   colorc                 C  sB   t | trzt|  W dS  ty   t|   Y dS w dS rS   )rN   r   	webcolorsname_to_hex
ValueErrornormalize_hexlowerrO   r   r   r   is_css21_color  s   
r   zjson-pointerc                 C  rR   rS   )rN   r   r9   jsonpointerJsonPointerrO   r   r   r   is_json_pointer  r   r   zrelative-json-pointerc                 C  s   t | tsdS | sdS g d}}t| D ]*\}}| r3|dkr-t| |d  dkr- dS || q|s8 dS | |d  } |dkpItt|S )NTFrY   r   r`   #)	rN   r   	enumerateisdigitintappendr9   r   r   )r2   non_negative_integerresti	characterr   r   r   is_relative_json_pointer  s    
	

r   zuri-template)rC   rD   rE   rF   c                 C  s   t | tsdS t| S rS   )rN   r   uri_templatevalidaterO   r   r   r   is_uri_template  s   

r   duration)rE   rF   r   c                 C  s&   t | tsdS t|  | tdS )NTDMYWHMS)rN   r   isodurationparse_durationendswithtuplerO   r   r   r   is_duration  s   

r   uuidc                   s,   t  tsdS t  t fdddD S )NTc                 3  s    | ]	} | d kV  qdS )-Nr   )r   positionrO   r   r   	<genexpr>  s    zis_uuid.<locals>.<genexpr>)            )rN   r   r   allrO   r   rO   r   is_uuid  s   
r   )NNNNNNNr   )r   r    )r2   r3   r   r9   )P
__future__r   
contextlibr   r   r   r   r   rT   r   typingr+   jsonschema.exceptionsr   Callabler3   r9   _FormatCheckCallableTypeVarr   UnionType	ExceptionTupler   r   ASCIIr   r
   draft3_format_checkerdraft4_format_checkerdraft6_format_checkerdraft7_format_checkerdraft201909_format_checkerdraft202012_format_checkerdictrG   r?   rK   rP   AddressValueErrorrV   r]   ImportErrorfqdnr^   rc   rd   	IDNAErrorUnicodeErrorrf   rx   rfc3986_validatorrg   ro   r   rs   rz   r}   rfc3339_validatorr   r   r   errorr   r   r   r   	TypeErrorr   r   JsonPointerExceptionr   r   r   r   r   DurationParsingExceptionr   r   r   r   r   r   <module>   s|    .	







	
3
