rc 7 0 UddlmZddlmZddlmZddlZddlZddlZddl Z ddl m Z e j e gefZe jdeZe je jee je jedffZGd d e ZeZeZeZeZeZeZeeeeeee Zd e d < dPdQdZ!e!de!ddRdZ"e!ddddddej#dRdZ$e!dej#dRdZ%ee&5dd l'm(Z(e!d!d"d"d"d"d" dRd#Z)dddn #1swxYwYee&5ddl*Z*e!d$d$d$e*j+e,f%dRd&Z-dddn #1swxYwY ddl.Z.e!d'd'd'e/%dRd(Z0e!d)d)d)e/%dRd*Z1e!d+e/dRd,Z2e!d-d-d-d-e/.dRd/Z3nd#e&$r\ee&5dd0l4m5Z5e!d+dRd1Z2e!d-d-d-d-e/.dRd2Z3dddn #1swxYwYYnwxYwee&5dd3l6m7Z7e!d4dRd5Z8e!d6d6d67dRd8Z9dddn #1swxYwYe!d9ej:dRd:Z;e!d;d;d;d;e/<dRd=Z<e!d6e/>dRd?Z=ee&5dd@l>m?Z?ddl>Z>dRdAZ@e!dBe/eAf>dRdCZBdddn #1swxYwYee&5ddlCZCe!dDdDdDdDeCjD.dRdEZEe!dFdFdFeCjD%dRdGZFdddn #1swxYwYee&5ddlGZGe!dHdHdHdHIdRdJZHdddn #1swxYwYee&5ddlIZIe!dKdKeIjJLdRdMZKdddn #1swxYwYe!dNdNe/LdRdOZLdS)S) annotations)suppress)UUIDN) FormatError_F)bound.cjeZdZUdZiZded<dddZdZ dddZe dddZ ddZ ddZ dS) FormatCheckera 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 check a custom format using a function that takes an instance and returns a ``bool``, use the `FormatChecker.checks` or `FormatChecker.cls_checks` decorators. Arguments: formats (~collections.abc.Iterable): The known formats to validate. This argument can be used to limit which formats will be used during validation. z3dict[str, tuple[_FormatCheckCallable, _RaisesType]]checkersNformatstyping.Iterable[str] | Nonec| j_dStfd|D_dS)Nc36K|]}|j|fVdSNr ).0kselfs 4/usr/lib/python3/dist-packages/jsonschema/_format.py z)FormatChecker.__init__..3s/ H H1!T]1%5!6 H H H H H H)r copydict)rr s` r__init__zFormatChecker.__init__/sI ? M..00DMMM H H H H H H HHHDMMMrcPdt|jS)Nz)formatsortedr )rs r__repr__zFormatChecker.__repr__5s ,33F4=4I4IJJJrrstrraises _RaisesTypereturntyping.Callable[[_F], _F]cdfd }|S)a Register a decorated function as validating a new format. Arguments: format (str): The format that the decorated function will check. raises (Exception): 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. funcrr#c |fj<|Srr)r&rr!rs r_checksz%FormatChecker.checks.._checksNs%)6NDM& !Krr&rr#rr)rrr!r(s``` rcheckszFormatChecker.checks8s4,        rcdfd }|S)Nr&rr#c |fj<|Srr)r&clsrr!s rr(z)FormatChecker.cls_checks.._checksXs$(&>CL Krr)r)r-rr!r(s``` r cls_checkszFormatChecker.cls_checksTs4        rinstanceobjectNonec||jvrdS|j|\}}d\}} ||}n#|$r }|}Yd}~nd}~wwxYw|st|d||dS)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 (str): 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)rr/rr&r!resultr3es rcheckzFormatChecker.check^s(  & & F}V, f"  T(^^FF   EEEEEE  PAAvAAOOO O P Ps .?:?boolcV |||dS#t$rYdSwxYw)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 (str): The format that instance should conform to Returns: bool: whether it conformed TF)r6r)rr/rs rconformszFormatChecker.conforms~sF&  JJx ( ( (4   55 s  ((r)r r )r)rr r!r"r#r$)r/r0rr r#r1)r/r0rr r#r7) __name__ __module__ __qualname____doc__r __annotations__rrr* classmethodr.r6r9rrrr r s2      IIIII KKK24802[PPPP@rr )draft3draft4draft6draft7 draft201909 draft202012zdict[str, FormatChecker]_draft_checkersrr#r$c\p|p|p|p|p|p|dfd }|S)Nr&rr#cfr)td|}r)td|}r)td|}r)td|}r)td|}r)td|}tp pppp||S)Nr@rArBrCrDrE)rFr*r r.)r&rDrEr@rArBrCr!s rwrapz_checks_drafts..wraps^  J"8,33FFCCDIID  J"8,33FFCCDIID  J"8,33FFCCDIID  J"8,33FFCCDIID  "=188fMMD  "=188fMMD    N; N& NF Nf N        rr)r) namer@rArBrCrDrEr!rIs ``````` r_checks_draftsrKs^tF ^tF ^tF ^tF%K%K4 Krz idn-email)rJemailr/r0r7c8t|tsdSd|vS)NT@) isinstancer r/s ris_emailrQs% h $ $t (?rz ip-addressipv4)r@rArBrCrDrEr!crt|tsdSttj|SNT)rOr r7 ipaddress IPv4AddressrPs ris_ipv4rWs4 h $ $t  %h// 0 00ripv6)rJr!c|t|tsdStj|}t |dd S)NTscope_id)rOr rU IPv6Addressgetattr)r/addresss ris_ipv6r_s> h $ $t#H--Gw B// //r)FQDNz host-namehostnamecXt|tsdSt|jSrT)rOr r`is_validrPs r is_host_namerds*(C(( 4H~~&&rz idn-hostname)rCrDrEr!c\t|tsdStj|dSrT)rOr idnaencoderPs ris_idn_host_namerh s0(C(( 4 Htriric\t|tsdStj|dS)NTIRIrulerOr rfc3987parserPs ris_irirq3s0(C(( 4}XE2222rz iri-referencec\t|tsdStj|dS)NT IRI_referencerlrnrPs ris_iri_referencert>s0(C(( 4}XO<<<.s-IIXx!S(IIIIIIr) )rOr rallrPs`ris_uuidrsJ h $ $tNNN IIIIIII I IIr)NNNNNNNr)r#r$)r/r0r#r7)M __future__r contextlibrrrrrUrtypingjsonschema.exceptionsrCallabler0r7_FormatCheckCallableTypeVarrUnionType ExceptionTupler"r draft3_format_checkerdraft4_format_checkerdraft6_format_checkerdraft7_format_checkerdraft201909_format_checkerdraft202012_format_checkerrrFr>rKrQAddressValueErrorrWr_ ImportErrorfqdnr`rdrf IDNAError UnicodeErrorrhro ValueErrorrqrtryr}rfc3986_validatorr~rfc3339_validatorrrrerrorrrrrrr TypeErrorrrJsonPointerExceptionrrrrrDurationParsingExceptionrrrrrrs8 """"""" ------x~6V^D 4555l K FLY)?)DEF CCCCCFCCCL& % % % *]__*]__,0D ** ---      +++++\[!!!W"!       &1111 VI$?@@@000A@0Xk''^ '''''''''''''''''''"XkKKK^"" -    "@=NNN2^  333  3 ^##  ===  = ^z222333323 ^## =====wDDD +  DD666666 U # # # : : : $ # : ""''     D D D   D!DDDDDDDDDDDDDDDDBXk55222222^%%%222&%2 ^ 555  5555555555555555(WRX...&&&/.&     NNNN vj111BBB21B Xk++,,,,,,1111^7J +BCCC+++DC++++++++++++++++"Xk-D-D^""/ 7777^&++/  DDD  D3-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D`Xk / /^""  ///  / / / / / / / / / / / / / / / /Xk : :^3 :::  : : : : : : : : : : : : : : : :  JJJ  JJJs"F  F F %GGGIJ%7J J%J J%J J%$J%35K44K8;K8(N  NN!AO//O36O3P//P36P3"Q33Q7:Q7