ff%ddlmZmZmZmZddlmZmZmZm Z m Z m Z ddl m Z dZGddeZeZdZGdd ee ZGd d eZd S))InvariantException CheckedType_restore_picklestore_invariants) set_fields check_typeis_field_ignore_extra_complaintPFIELD_NO_INITIAL serializecheck_global_invariants transformcJt|dko|dtkS)Nr)lenr)basess r/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/_pclass.py _is_pclassrs u::? 6uQx;66ceZdZfdZxZS) PClassMetac*t||dt||dddtd|dDz|d<t|r|dxxdz cc<t t |||||S) N_pclass_fields)name_pclass_invariants __invariant__)_pclass_frozenc3K|]}|VdSN).0keys r z%PClassMeta.__new__..s"6\6\ss6\6\6\6\6\6\r __slots__) __weakref__)rrtuplersuperr__new__)mcsrrdct __class__s rr(zPClassMeta.__new__ s3$45555e%9?KKK.6\6\cJZF[6\6\6\1\1\\K e   1     0 0   Z%%--c4DDDr)__name__ __module__ __qualname__r( __classcell__r+s@rrr sA E E E E E E E E Errct||||||\}}|s||dSt|||dSr)r invariantappendsetattr)clsfieldrvalueresultinvariant_errorsis_ok error_codes r_check_and_set_attrr<sfsE4'''..E: % +++++e$$$$$rceZdZdZfdZdZeddZddZdZ d Z d Z d Z fd Z d ZdZdZdZdZdZxZS)PClassa A PClass is a python class with a fixed set of specified fields. PClasses are declared as python classes inheriting from PClass. It is defined the same way that PRecords are and behaves like a PRecord in all aspects except that it is not a PMap and hence not a collection but rather a plain Python object. More documentation and examples of PClass usage is available at https://github.com/tobgu/pyrsistent c tt||}|dd}|dd}g}g}|jD]\}}||vrv|||vrPt t||r||||} n$|||} n||} t|||| ||||=|j turDt|j r| n|j } t|||| |||j r.| d|j| |s|r+t!t#|t#|d|r;t%dd||jt)||jd|_|S) N_factory_fields ignore_extra)rAz{0}.{1}zField invariant failedz0'{0}' are not among the specified fields for {1}, T)r'r>r(popritemsr factoryr<initialr callable mandatoryr3formatr,rr&AttributeErrorjoinr rr) r5kwargsr8factory_fieldsrAmissing_fieldsr9rr6r7rFr+s rr(zPClass.__new__.s"vs##++C00$5t<<zz.$77 -3355 L LKD%v~~!)T^-C-C6vulSS< % fTl V V % fTl ; ;"4LE#CeVEUVVV4LL&777-5em-D-DW%--///%-#gv7GIIII L%%i&6&6s|T&J&JKKK  o~ o$U+;%<%S>SUmnn n  2 !S!Z!Z &!!3<"1"122 2 (>??? $ rc|r|d||d<t|}|jD]*}||vr$t||t}|tur|||<+|jdd|i|S)a Set a field in the instance. Returns a new instance with the updated value. The original instance remains unmodified. Accepts key-value pairs or single string representing the field name and a value. >>> from pyrsistent import PClass, field >>> class AClass(PClass): ... x = field() ... >>> a = AClass(x=1) >>> a2 = a.set(x=2) >>> a3 = a.set('x', 3) >>> a AClass(x=1) >>> a2 AClass(x=2) >>> a3 AClass(x=3) rrr@r )setrgetattr_MISSING_VALUEr+)selfargsrLrMr"r7s rrPz PClass.setRs&  &"1gF47OV& ( (C&  c>::.."'F3Kt~GGnGGGGrNFcht|rS|rfd|jD|d||dS)a: Factory method. Will create a new PClass of the current type and assign the values specified in kwargs. :param ignore_extra: A boolean which when set to True will ignore any keys which appear in kwargs that are not in the set of fields on the PClass. c*i|]}|v||Sr r )r!krLs r z!PClass.create..s$NNNq!v++a+++r)r@rAr ) isinstancer)r5rLr@rAs ` rcreatez PClass.creaters_ fc " " M  ONNNNC,>NNNFsX?XXQWXXXrci}|jD]E}t||t}|tur$t|j|j||||<F|S)z Serialize the current PClass using custom serializer functions for fields where such have been supplied. )rrQrRr serializer)rSrIr8rr7s rr zPClass.serializes` ' ^ ^DD$77EN**().s4cc3c> B BCccccccr)hashr&rrSs`r__hash__zPClass.__hash__s1EcccctObcccccdddrct|ddr#td||tt|||dS)NrFz'Can't set attribute, key={0}, value={1})rQrJrIr'r> __setattr__rSr"r7r+s rrlzPClass.__setattr__s` 4)5 1 1 _ !J!Q!QRUW\!]!]^^ ^ fd''U33333rcFtd|)Nz-Can't delete attribute, key={0}, use remove())rJrI)rSr"s r __delattr__zPClass.__delattr__s  !P!W!WX[!\!\]] ]rcfi}|jD]&}t||t}|tur|||<'|Sr)rrQrR)rSr8r"r7s r_to_dictzPClass._to_dictsD& $ $CD#~66EN**#s  rcd|jjdd|DS)Nz{0}({1})rBc3bK|]*\}}d|t|V+dS)z{0}={1}N)rIrepr)r!rWvs rr#z"PClass.__repr__..s<*l*lDAq9+;+;AtAww+G+G*l*l*l*l*l*lr)rIr+r,rKrqrDris r__repr__zPClass.__repr__s[  !8!%*l*lTXTaTaTcTcTiTiTkTk*l*l*l!l!lnn nrcdtfdjD}tj|ffS)Nc3\K|]&}t||t|fV'dSr)hasattrrQrgs rr#z$PClass.__reduce__..sDcc#PWX\^aPbPbcS'$,,-ccccccr)dictrrr+)rSdatas` r __reduce__zPClass.__reduce__s:cccc9Lccccc 777rcFt||S)z5 Returns an evolver for this object. )_PClassEvolverrqris revolverzPClass.evolversdDMMOO444rcX|}||=|S)z Remove attribute given by name from the current instance. Raises AttributeError if the attribute doesn't exist. )r persistent)rSrrs rremovez PClass.removes* ,,.. DM!!###rNFr)r,r-r.__doc__r(rP classmethodrZr rrbrdrjrlrorqrvr|rrr/r0s@rr>r>%sF"""""HHHH@YYY[Y    000!!!eee44444 ^^^nnn888 555 $$$$$$$rr>) metaclasscReZdZdZdZdZdZdZdZdZ dZ fd Z d Z xZ S) r~)_pclass_evolver_original_pclass_evolver_data_pclass_evolver_data_is_dirtyr@cV||_||_d|_t|_dSr)rrrrPr@)rSoriginal initial_dicts r__init__z_PClassEvolver.__init__s,(0%$0!-2*"uurc|j|Sr)rrSitems r __getitem__z_PClassEvolver.__getitem__s(..rc|j|t|ur+||j|<|j|d|_|SNT)rgetrRr@addrrSr"r7s rrPz_PClassEvolver.setsQ  $ ( (n = =U J J-2D %c *  $ $S ) ) )15D . rc2|||dSr)rPrs r __setitem__z_PClassEvolver.__setitem__s erc||jvr+|j|=|j|d|_|St |r)rr@discardrrJrs rrz_PClassEvolver.removesM 4, , ,)$/  ( ( . . .15D .KT"""rc0||dSr)rrs r __delitem__z_PClassEvolver.__delitem__s DrcZ|jr|jjdd|ji|jS|jS)Nr@r )rrr+r@rris rrz_PClassEvolver.persistentsS  - X:40:XX4K_X=A=VXX X,,rc||jvr|||dStt|||dSr)r$rPr'r~rlrms rrlz_PClassEvolver.__setattr__sP dn $ $ HHS% .$ ' ' 3 3C ? ? ? ? ?rc||Srr rs r __getattr__z_PClassEvolver.__getattr__s Dzr)r,r-r.r$rrrPrrrrrlrr/r0s@rr~r~sxI%%% ///###---@@@@@ rr~N)pyrsistent._checked_typesrrrrpyrsistent._field_commonrrr r r r pyrsistent._transformationsrrtyperobjectrRr<r>r~r rrrsYjjjjjjjjjjjj211111777 E E E E E E E E%%%m$m$m$m$m$[Jm$m$m$m$`11111V11111r