L i< UddlmZddlmZddlmZmZddlmZddlZddl Z ddl Z ddl Z ddl m Z e jegefZe j$deZe j(eeeeed ffZe j2d e j4ZGd d ZeZeZeZeZ eZ!eZ"e#eeee e!e" Z$de%d< dM dNdZ&e&de&ddOdZ'e&ddddddejPdOdZ)e&dejPdOdZ*ee+5ddl,m-Z-e&dddddde.dOdZ/dddee+5ddl0Z0e&d d d e0jbe2f!dOd"Z3ddd ddl4Z4e&d#d#d#e.!dOd$Z5e&d%d%d%e.!dOd&Z6e&d'e.dOd(Z7e&d)d)d)d)e.*dOd+Z8ee+5dd2l>m?Z?e&d3dOd4Z@e&d5d5d56dOd7ZAddde&d8e jdOd9ZCe&d:d:d:d:e.;dOd<ZDe&d5e.=dOd>ZEee+5ddlFZFe&d?e.eGf=dOd@ZHdddee+5ddlIZIe&dAdAdAdAeIj*dOdBZKe&dCdCdCeIj!dOdDZLdddee+5ddlMZMe&dEdEdEdEFdOdGZNdddee+5ddlOZOe&dHdHeOjIdOdJZQddde&dKdKe.IdOdLZRy#1swYxYw#1swYxYw#e+$ree+5dd,l9m:Z:e&d'dOd-Z7e&d)d)d)d)e.*dOd.Z8dddn #1swYnxYwee+5dd/l;mDMM!,,> >sAc4dt|jdS)Nz)sortedr )rs r__repr__zFormatChecker.__repr__6s)&*?)@BBcdfd }|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. c*|fj<|Srr )funcformatraisesrs r_checksz%FormatChecker.checks.._checksPs%)6NDMM& !Krrr returnr )rrr r!s``` rcheckszFormatChecker.checks9s. rc`tjdtd|j||S)NzoFormatChecker.cls_checks is deprecated. Call FormatChecker.checks on a specific FormatChecker instance instead.) stacklevel)rr )warningswarnDeprecationWarning _cls_checks)clsrr s r cls_checkszFormatChecker.cls_checksVs2    fV<._checksis$(&>CLL Krr"r$)r-rr r!s``` rr,zFormatChecker._cls_checkses rc||jvry|j|\}}d\}} ||}|st|d||y#|$r }|}Yd}~!d}~wwxYw)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)rinstancerrr resultr2es rcheckzFormatChecker.checkosu*  & }}V, f"  (^F JvjAO O E sAA AAcH |j||y#t$rYywxYw)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 TF)r6r)rr3rs rconformszFormatChecker.conformss.&  JJx (  s  !!r)rztyping.Iterable[str] | None)r$)rstrr _RaisesTyper#typing.Callable[[_F], _F])r3objectrr9r#None)r3r<rr9r#bool)__name__ __module__ __qualname____doc__r __annotations__rrr% classmethodr.r,r6r8r$rrr r s2   ? C24#. ":02 = ="- = " = =02"- "PBrr )draft3draft4draft6draft7 draft201909 draft202012zdict[str, FormatChecker]_draft_checkersctxs|xs|xs|xs|xs|xs|dfd }|S)Ncrtdj|}rtdj|}rtdj|}rtdj|}rtdj|}rtdj|}tjxsxsxs xsxs||S)NrErFrGrHrIrJ)rKr%r r,)rrIrJrErFrGrHr s rwrapz_checks_drafts..wraps "8,33FFCDID "8,33FFCDID "8,33FFCDID "8,33FFCDID "=188fMD "=188fMD !!  N; N& NF Nf N     rr"r$) namerErFrGrHrIrJr rNs ``````` r_checks_draftsrPsN^tF ^tF ^tF ^tF%K%K4 Krz idn-email)rOemailc,t|tsyd|vS)NT@) isinstancer9r3s ris_emailrVs h $ (?rz ip-addressipv4)rErFrGrHrIrJr c`t|tsyttj|SNT)rTr9r> ipaddress IPv4AddressrUs ris_ipv4r\s' h $  %%h/ 00ripv6)rOr cjt|tsytj|}t |dd S)NTscope_id)rTr9rZ IPv6Addressgetattr)r3addresss ris_ipv6rds1 h $##H-Gw B/ //r)FQDNz host-namehostnamecRt|tsyt|djS)NT) min_labels)rTr9reis_validrUs r is_host_namerk s$(C(H+444rz idn-hostname)rHrIrJr cPt|tsytj|yrY)rTr9idnaencoderUs ris_idn_host_namero"s (C( HriricRt|tsytj|dS)NTIRIrulerTr9rfc3987parserUs ris_irirxbs"(C(}}XE22rz iri-referencecRt|tsytj|dS)NT IRI_referencersrurUs ris_iri_referencer{ms"(C(}}XO<t|tsyt|dSr~rTr9rrUs rrr5sh,#H59 9rc>t|tsyt|dSrrrUs rrr;sh,#H?C Cr)is_valid_syntaxc<t|tsytd|S)NTrprTr9_rfc3987_is_valid_syntaxrUs rrxrxJsh,+E8< recompilerUs ris_regexrs# h $  8$ %%rr)rErHrIrJr ct|tsyttj |xrt j |SrY)rTr9r>_RE_DATE fullmatchr fromisoformatrUs ris_daters7 h $ ""8,M1C1CH1M NNr)rEr cbt|tsyttj|dS)NTz%H:%M:%S)rTr9r>rstrptimerUs ris_draft3_timers' h $ !!(J7 88rcolorct|tr tj|yy#t$r&tj |j YywxYwrY)rTr9 webcolors name_to_hex ValueError normalize_hexlowerrUs ris_css21_colorrsM h $ :%%h/ :''(89 :s),AAz json-pointerc`t|tsyttj|SrY)rTr9r> jsonpointer JsonPointerrUs ris_json_pointerrs'(C(K++H566rzrelative-json-pointerc0t|tsy|sygd}}t|D]L\}}|jr-|dkDrt ||dz dk(ry|j |C|sy||d}n|dk(xst tj|S)NTFr`rrh#) rTr9 enumerateisdigitintappendr>rr)r3non_negative_integerresti characters ris_relative_json_pointerrs(C(%'d%h/ LAy  "q5S!a%1Q6 $++I6'ABzis_uuid.."sIXx!S(Is) )rTr9rallrUs`ris_uuidrs* h $N II IIr)NNNNNNNr$)r#r;)r3r<r#r>)S __future__r contextlibrrrrrrZrtypingr)jsonschema.exceptionsrCallabler<r>_FormatCheckCallableTypeVarr Uniontype Exceptionrr:rASCIIrr draft3_format_checkerdraft4_format_checkerdraft6_format_checkerdraft7_format_checkerdraft201909_format_checkerdraft202012_format_checkerdictrKrCrPrVAddressValueErrorr\rd ImportErrorfqdnrerrkrm IDNAError UnicodeErrorrorvrxr{rrrfc3986_validatorrrfc3987_syntaxrrrfc3339_validatorrrrerrorrrrr TypeErrorrrJsonPointerExceptionrrrrrDurationParsingExceptionrrr$rrrs"# -x~6V^^D 45ll4 ?E$y/32F,GGH 2::,bhh 7SSl&%%%*_*_,0 ** -)      ++\[!W"       & &11 VI$?$?@0A0k5 5 55*k"" -    "Y=d  3  3 ##  =  = z2333 ## == k52%2&2  5  55(WRXX.&/&     OO vj1929 k 7J +BCD k0D""// 77&++//  D  D30Dfk /""  /  / /k 333 3  3 3   J  Jk55*&-G + D6 U # : $ : ""''   D  D!DDD* + GN    =   = "''   G   G)GGG--Gt55^  0D0Df / / 3 3sM 2$MM%6)P/PAP'P*!P7 MM"% P2+N& P&N/ +P:-O0' P0O9 5P?PP PP'*P47Q