online # ˆl–Ãa¾”TÂXÔ%ÍÆ^¸TÅ£Á ƒ}ç›À¿Ä&� a `Å]_æ%ã@s’ddlmZmZmZmZddlmZmZmZm Z m Z m Z ddl m Z dd„ZGdd„deƒZeƒZdd „ZGd d „d eed �ZGd d„deƒZdS)é)ÚInvariantExceptionÚ CheckedTypeÚ_restore_pickleÚstore_invariants)Ú set_fieldsÚ check_typeÚis_field_ignore_extra_complaintÚPFIELD_NO_INITIALÚ serializeÚcheck_global_invariants©Ú transformcCst|ƒdko|dtkS)Nér)Úlenr)Úbases©rú8/usr/lib64/python3.9/site-packages/pyrsistent/_pclass.pyÚ _is_pclasssrcseZdZ‡fdd„Z‡ZS)Ú PClassMetacsht||dd�t||ddƒdtdd„|dDƒƒ|d<t|ƒrR|dd 7<tt|ƒ ||||¡S) NÚ_pclass_fields)ÚnameÚ_pclass_invariantsZ __invariant__)Ú_pclass_frozencss|] }|VqdS©Nr©Ú.0ÚkeyrrrÚ óz%PClassMeta.__new__..Ú __slots__)Ú __weakref__)rrÚtuplerÚsuperrÚ__new__)ZmcsrrZdct©Ú __class__rrr# s zPClassMeta.__new__)Ú__name__Ú __module__Ú __qualname__r#Ú __classcell__rrr$rr srcCs<t||||ƒ| |¡\}}|s,| |¡n t|||ƒdSr)rZ invariantÚappendÚsetattr)ÚclsÚfieldrÚvalueÚresultÚinvariant_errorsZis_okZ error_coderrrÚ_check_and_set_attrs  r1csœeZdZdZ‡fdd„Zdd„Zed"dd „ƒZd#d d „Zd d „Z dd„Z dd„Z dd„Z ‡fdd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Z‡ZS)$Ú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  sRtt|ƒ |¡}| dd¡}| dd¡}g}g}|j ¡D]Â\}}||vr¬|dusZ||vrŠtt||ƒrz|j|||d�} q’| ||¡} n||} t|||| ||ƒ||=q:|j t urât |j ƒrÈ|  ¡n|j } t|||| ||ƒq:|j r:|  d |j|¡¡q:|�s |�rtt|ƒt|ƒdƒ‚|�r>> 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) rrr3)ÚsetrÚgetattrÚ_MISSING_VALUEr%)ÚselfÚargsr>r?rr.rrrr@Rs   z PClass.setNFcs:tˆ|ƒrˆS|r&‡fdd„|jDƒ‰|f||dœˆ¤ŽS)a: Factory method. Will create a new PClass of the current type and assign the values specified in kwargs.