U e/@szddlmZddlZddlZddlZddlZddlZGdddeZ e ddZ dde e _ ejd d Zejd d Zd dZddZddZddZddZddZeddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Z d+d,Z!d-d.Z"d/d0Z#e d1d2Z$ee$_%ee$_&ee$_'e d3d4Z(ee(_%ee(_)ee(_&ee(_'e d5d6Z*ee*_%ee*_&ee*_'e d7d8Z+ee+_%ee+_)ee+_&ee+_'e d9d2Z,ee,_%ee,_&ee,_'e d:d;Z-dZ0de:e?Z@e:eAdWdXZBe:eAdYdXZCdZd[ZDd\d]ZEd^d_ZFd`daZGdbdcZHdddeZIdfdgZJe fddhdidjZKdS)l) annotationsNcs&eZdZdfdd ZddZZS)ValidationErrorNcst|||_||_dSN)super__init__ error_msgctx)selfrr __class__2/opt/hc_python/lib/python3.8/site-packages/cfgv.pyr s zValidationError.__init__cCs@d}|}|jdk r,|d|jd7}|j}q|d|j7}|S)N z==> z=====> )rr)r outerrr r r __str__s zValidationError.__str__)N)__name__ __module__ __qualname__rr __classcell__r r r r r srMissingr cCsdS)NMISSINGr r r r r rc csTz dVWnDtk rN}z&t\}}}t||d|dW5d}~XYnXdS)N)rrsysexc_infowith_traceback)msge_tbr r r validate_contexts  r#c csPz dVWn@tk rJ}z"t\}}}|||dW5d}~XYnXdSrr)tpr r!r"r r r reraise_as's  r%cCsdSrr r dctr r r _dct_noop0sr(c Cs>|j|krdStd|j|||jW5QRXdS)NzAt key: )keyr#check_fnr&r r r _check_optional4s r+cCs||j|jdSr) setdefaultr)defaultr&r r r _apply_default_optional;sr.cCs ||jt|jkr||j=dSr)getr)rr-r&r r r _remove_default_optional?sr0cCs|j|krtd|jdS)NzMissing required key: )r)rr&r r r _require_keyDs r1cCst||t||dSr)r1r+r&r r r _check_requiredIs r2csfdd}|S)Ncst|jdSr)validateschemavalrr r r*Psz#_check_fn_recurse..check_fnr )r r*r rr _check_fn_recurseNs r7cCst||j|j||j<dSr)apply_defaultsr)r4r&r r r _apply_default_required_recurseUsr9cCst||j|j||j<dSr)remove_defaultsr)r4r&r r r _remove_default_required_recurseYsr;cCs"|j|krt||t||dSr)r)r.r9r&r r r _apply_default_optional_recurse]s  r<cCs"|j|krt||t||dSr)r)r;r0r&r r r _remove_default_optional_recursecs  r=csfdd}|S)Nc s||jt|jkr ||np|j|kr|jr|j|krt|jdrR|j}n d|j}td|jd|jd|d|jd||j dS)Ndescribe_oppositezis not Expected z to be absent when  z, found z: ) r/ condition_keyrcondition_value ensure_absentr)hasattrr>r)r r'Z explanationinnerr r _check_conditionaljs    ,z2_get_check_conditional.._check_conditionalr )rFrGr rEr _get_check_conditionalis rHcCs"||jt|jkrt||dSr)r/rArrBr.r&r r r #_apply_default_conditional_optional|srIcCs"||jt|jkrt||dSr)r/rArrBr0r&r r r $_remove_default_conditional_optionalsrJcCs"||jt|jkrt||dSr)r/rArrBr9r&r r r "_apply_default_conditional_recursesrKcCs"||jt|jkrt||dSr)r/rArrBr;r&r r r #_remove_default_conditional_recursesrLcCs\tt|t|j}|rXddd|D}ddd|jD}td|d|dS)N, css|]}t|VqdSrstr.0xr r r sz,_no_additional_keys_check..css|]}t|VqdSrrNrPr r r rSszAdditional keys found: z . Only these keys are allowed: )sortedsetkeysjoinr)r r'extraZextra_sZkeys_sr r r _no_additional_keys_checksrYcCs.tt|t|j}|r*|||j|dSr)rTrUrVcallback)r r'rXr r r _warn_additional_keys_checksr[Required)r)r*RequiredRecurse)r)r4Optional)r)r*r-OptionalRecurse)r)r4r-OptionalNoDefault Conditional)r)r*rArBrC)FConditionalOptional)r)r*r-rArBrCConditionalRecurse)r)r4rArBrCNoAdditionalKeys)rVWarnAdditionalKeys)rVrZcs8eZdZdZfddZddZddZdd ZZS) Mapr cst||||Srr__new__)cls object_nameid_keyitemsr r r rhsz Map.__new__c Cst|ts&td|jdt|j|jdkr@d|jd}n*||jt}d|jd|jd|d}t ||j D]}| |qzW5QRXdS)Nz Expected a z map but got a zAt z()(=)) isinstancedictrrjtyperrkr/rr#rlcheck)r vcontextZkey_v_sitemr r r rss    z Map.checkcCs"|}|jD]}||q|Sr)copyrl apply_defaultr rtretrvr r r r8s  zMap.apply_defaultscCs"|}|jD]}||q|Sr)rwrlremove_defaultryr r r r:s  zMap.remove_defaults rrr __slots__rhrsr8r:rr r r r rfs  rf)rjrkrlcs:eZdZdZd fdd ZddZddZd d ZZS) Arrayr Tcstj|||dS)Nof allow_emptyrg)rirrr r r rhsz Array.__new__cCsDtt||js*|s*td|jjd|D]}t||jq.dS)NzExpected at least 1 '') check_array check_anyrrrrjr3)r rtr6r r r rs s  z Array.checkcsfdd|DS)Ncsg|]}t|jqSr )r8rrQr6rr r sz(Array.apply_defaults..r r rtr rr r8szArray.apply_defaultscsfdd|DS)Ncsg|]}t|jqSr )r:rrrr r rsz)Array.remove_defaults..r rr rr r:szArray.remove_defaults)Tr|r r r r r~s  r~rc@s eZdZdZddZddZdS)Notr cCs d|jS)Nzis r5rr r r r>szNot.describe_oppositecCs|tk o||jkSr)rr6r otherr r r __eq__!sz Not.__eq__N)rrrr}r>rr r r r rsrr5cs0eZdZdZfddZddZddZZS)NotInr cstj||dSNvaluesrgrirr r r rh(sz NotIn.__new__cCs d|jS)Nz is any of rrr r r r>+szNotIn.describe_oppositecCs|tk o||jkSrrrrr r r r.sz NotIn.__eq__rrrr}rhr>rrr r r r r%s rrcs0eZdZdZfddZddZddZZS)Inr cstj||dSrrgrr r r rh5sz In.__new__cCs d|jS)Nzis not any of rrr r r r>8szIn.describe_oppositecCs|tk o||jkSrrrr r r r;sz In.__eq__rr r r r r2s rcCsdSrr )r!r r r r?srcsfdd}|S)Ncs2t|s.pj}td|dt|jdS)Nr?z got )rprrrr)rtZ typename_sr$typenamer r check_type_fnDs   z!check_type..check_type_fnr )r$rrr rr check_typeCsrstring)rtextcsfdd}|S)Ncs8|kr4dddtD}td|d|dS)NrMcss|]}t|VqdSrrNrPr r r rSWsz8check_one_of..check_one_of_fn..zExpected one of z but got: )rWrTr)rtZ possible_spossibler r check_one_of_fnUs z%check_one_of..check_one_of_fnr )rrr rr check_one_ofTs rcCs8zt|Wn$tjk r2t|dYnXdS)Nz is not a valid python regex)recompileerrorr)rtr r r check_regex^srcsfdd}|S)Nc sZt|ttfs"tdt|jt|D]*\}}td||W5QRXq*dS)NzExpected array but got z At index )rplisttuplerrrr enumerater#)rtir6 inner_checkr r check_array_fnfsz#check_array..check_array_fnr )rrr rr res rcsfdd}|S)NcsD] }||qdSrr )rtfnfnsr r rssszcheck_and..checkr )rrsr rr check_andrs rcCs|||Sr)rsrtr4r r r r3ys r3cCs ||Sr)r8rr r r r8~sr8cCs ||Sr)r:rr r r r:sr:)display_filenamec Cs |p|}t|tj|s,t|dtd|z$t|dd}|}W5QRXWn.tk r}ztt |W5d}~XYnXz ||}Wn.t k r}ztt |W5d}~XYnXt ||t ||W5QRW5QRSQRXW5QRXdS)Nz is not a filezFile zutf-8)encoding) r%ospathisfilerr#openreadUnicodeDecodeErrorrO Exceptionr3r8) filenamer4Z load_strategyZexc_tprfcontentsr datar r r load_from_filenames     r)N)L __future__r collections contextlibos.pathrrr ValueErrorr namedtuplerrr__repr__contextmanagerr#r%r(r+r.r0r1r2propertyr7r9r;r<r=rHrIrJrKrLrYr[r\rsrxr{r]r*r^r_r`rarh __defaults__rbrcrdrerfr~rrrrrboolZ check_boolbytesZ check_bytesintZ check_intrOZ check_string check_textrrrrr3r8r:rr r r r s            "