ff.bddlmZmZmZmZmZmZmZmZm Z ddlm Z ddlm Z ddl Z dZdZdZdZd Zd ZGd d eZd ZdZdZeZdZeeedeefdZdZGddeZedediZiZ dZ!dZ"dZ#eefdZ$dd eefdZ%dd eefdZ&dZ'iZ(dZ)d Z*defd!Z+dS)") CheckedPMap CheckedPSetCheckedPVector CheckedTypeInvariantException_restore_pickleget_typemaybe_parse_user_typemaybe_parse_many_user_types)optional)wrap_invariantNcttfd|Dg|<t|D](\}}t |t r|||<||=)dS)Ncg|]<}t|ji=S)list__dict__getitems).0bnames x/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/_field_common.py zset_fields..s=PPPQ$qz~~dB77==??@@PPP)dictsumrr isinstance_PField)dctbasesrkvs ` r set_fieldsr#sSPPPP%PPPRTUUVVCISYY[[!!1 a ! ! CIaLArcxtdfd|DD}|rt|dddS)Nc3$K|] \}}||V dSNr)ris_ok error_codes r z*check_global_invariants..sHWW'8ujPUW WWWWWWrc3.K|]}|VdSr&r)r invariantsubjects rr)z*check_global_invariants..s-HH 7++HHHHHHrrzGlobal invariant failed)tupler)r, invariants error_codess` rcheck_global_invariantsr0sqWWHHHHZHHHWWWWWKM b2KLLLMMrct|tr|tur||S|||Sr&)rrPFIELD_NO_SERIALIZER serialize) serializerformatvalues rr3r3!sC%%%'*8L*L*Lv&&& :fe $ $$rc|jrhtfd|jDsJt}d|j||j}t |||j||dSdS)Nc3RK|]!}tt|V"dSr&)rr )rtr6s rr)zcheck_type..)s3QQj <<QQQQQQrz'Invalid type for field {0}.{1}, was {2})typeanyr5__name__ PTypeError)destination_clsfieldrr6 actual_typemessages ` r check_typerB(s zR#QQQQejQQQQQR5kk ;BB?C[]acncwxx$ KQQQRRRRrct|turdSt|}t|dkrdSt t |d|S)NTrF)r:setr-len issubclassr )type_cls field_typetypess r is_type_clsrJ/sW J3t *  E 5zzQu huQx((( 3 33rcx|sdSt||jsdSdtj|jjvS)NF ignore_extra)rJr:inspect signaturefactory parameters)rGr?rLs ris_field_ignore_extra_complaintrQ8sC u x , ,u W.u}==H HHrc.eZdZdZdZedZdS)rr:r+initial mandatory_factoryr4cZ||_||_||_||_||_||_dSr&rS)selfr:r+rTrUrOr4s r__init__z_PField.__init__Gs0 " " $rc|jtur[t|jdkrCt t |jd}t |tr|jS|jS)Nr) rVPFIELD_NO_FACTORYrEr:r r-rFrcreate)rXtyps rrOz_PField.factoryOsb =- - -#di..A2E2E5++A.//C#{++ "z!}rN)r< __module__ __qualname__ __slots__rYpropertyrOrrrrrDsCWI%%%XrrrcdS)N)TNr)_s rreZs rc|Sr&r)xs rrere[sarc|Sr&r)rdr6s rrere]srFcZt|tttfrtt |}ntt |}|t krt|rt|n|}t||||||}t||S)a Field specification factory for :py:class:`PRecord`. :param type: a type or iterable with types that are allowed for this field :param invariant: a function specifying an invariant that must hold for the field :param initial: value of field if not specified when instantiating the record :param mandatory: boolean specifying if the field is mandatory or not :param factory: function called when field is set. :param serializer: function that returns a serialized version of the field )r:r+rTrUrOr4) rrrDr-r r PFIELD_NO_INVARIANTcallabler r_check_field_parameters) r:r+rTrUrOr4rIinvariant_functionr?s rr?r?`s,$sE*++1/5566)$//006?CV6V6V[cdm[n[n6V 222t} *.s/"T"TA:emQ#?#?"T"T"T"T"T"TrzInitial has invalid type {0}zInvariant must be callablezFactory must be callablezSerializer must be callable) r:rstr TypeErrorr5rTPFIELD_NO_INITIALrkr;r+rOr4)r?r9s` rrlrlsG ZPP!T"" P:a+=+= P>EEd1ggNNOO O }---''. J.""T"T"T"T"T"T"TTT.6==d5=>Q>QRRSSS EO $ $64555 EM " "42333 E$ % %7566677rc"eZdZdZfdZxZS)r=a Raised when trying to assign a value with a type that doesn't match the declared type. Attributes: source_class -- The class of the record field -- Field name expected_types -- Types allowed for the field actual_type -- The non matching type ctt|j|i|||_||_||_||_dSr&)superr=rY source_classr?expected_typesr@)rXrvr?rwr@argskwargs __class__s rrYzPTypeError.__init__sJ(j$($9&999( ,&r)r<r_r`__doc__rY __classcell__)rzs@rr=r=sB'''''''''rr=PVectorPSetc@t||f}t||S)z=Unpickling function for auto-generated PVec/PSet field types.)_seq_field_typesr) checked_class item_typedatatype_s r_restore_seq_field_picklers! ]I5 6E 5$ ' ''rc@dd|DS)z4Convert a tuple of types to a human-readable string.c3bK|]*}t|jV+dSr&)r r< capitalize)rr^s rr)z"_types_to_names..s7HH38C==)4466HHHHHHr)join)rIs r_types_to_namesrs# 77HH%HHH H HHrctf}||SGfdd}t}t|j|z|_|tf<|S)zFCreate a subclass of the given checked class with the given item type.Nc$eZdZZZfdZdS)%_make_seq_field_type..TheTypec6tt|ffSr&)rr)rXrrs r __reduce__z0_make_seq_field_type..TheType.__reduce__s -"ItDzz:< >GG18]I-. Nrc t||||rdfd }nj}t|rtn|d|||S)a Create checked field for either ``PSet`` or ``PVector``. :param checked_class: ``CheckedPSet`` or ``CheckedPVector``. :param item_type: The required type for the items in the set. :param optional: If true, ``None`` can be used as a value for this field. :param initial: Initial value to pass to factory. :return: A ``field`` containing a checked class. NFc<|dS|||S)N)_factory_fieldsrLr])argumentrrLrs rrOz _sequence_field..factorys't~~h^j~kkkrT)r:rOrUr+rT)NF)rr]r? optional_type)rrr rTr+rrOrs @r_sequence_fieldrs#=)^LLG! l l l l l l l . EmG,,,g D$ )) + + ++rc6tt|||||S)al Create checked ``PSet`` field. :param item_type: The required type for the items in the set. :param optional: If true, ``None`` can be used as a value for this field. :param initial: Initial value to pass to factory if no value is given for the field. :return: A ``field`` containing a ``CheckedPSet`` of the given type. r+r)rrrr rTr+rs r pset_fieldrs) ; 8W%.*8 : : ::rc6tt|||||S)au Create checked ``PVector`` field. :param item_type: The required type for the items in the vector. :param optional: If true, ``None`` can be used as a value for this field. :param initial: Initial value to pass to factory if no value is given for the field. :return: A ``field`` containing a ``CheckedPVector`` of the given type. r)rrrs r pvector_fieldrs) >9h%.*8 : : ::rcdS)N)Trr)items rreresjrc@t||f}t||S)z8Unpickling function for auto-generated PMap field types.)_pmap_field_typesr)key_type value_typerrs r_restore_pmap_field_picklers! h 2 3E 5$ ' ''rc tf}||SGfddt}dt |jt |j|_|tf<|S)zDCreate a subclass of CheckedPMap with the given key and value types.NceZdZZZdZdS)%_make_pmap_field_type..TheMapcHt|j|jt|ffSr&)r __key_type____value_type__r)rXs rrz0_make_pmap_field_type..TheMap.__reduce__(s'.&(;T$ZZHJ JrN)r<r_r`rrr)rrsrTheMapr$s3 # J J J J Jrrz {0}To{1}PMap)rrrr5r_checked_key_types_checked_value_typesr<)rrrrs`` r_make_pmap_field_typers  ! !8Z"8 9 9E  JJJJJJJJJJJ%++12234466FO/5h *+ Mrct|||rfd}nj}td|rtn||S)ad Create a checked ``PMap`` field. :param key: The required type for the keys of the map. :param value: The required type for the values of the map. :param optional: If true, ``None`` can be used as a value for this field. :param invariant: Pass-through to ``field``. :return: A ``field`` containing a ``CheckedPMap``. c6|dS|Sr&r)rrs rrOzpmap_field..factoryBs t}}X...rT)rUrTr:rOr+)rr]r?r)rrr r+rOrs @r pmap_fieldr3s~#8Z 8 8F  / / / / / / - 4/7CmF+++V I 7 7 77r),pyrsistent._checked_typesrrrrrrr r r r rr rMr#r0r3rBrJrQobjectrPFIELD_NO_TYPErjr\rrr2r?rlrqr=rrrrrrrr_validrrrrrrrrs                      @?????444444MMM%%%RRR444IIIf*,,KFHH--)$)",1::::&',R/!4::::& ! ((( */4?R777777r