U e@sddlTddgZdZGdddeZGdddeZeede fd e d Z e dd d Z e d dZ e ddZede fe ZeZ[ dS))* NamedConstantConstantNcs,eZdZdZfddZfddZZS)NamedConstantDictzTrack constant order and ensure names are not reused. NamedConstantMeta will use the names found in self._names as the Constant names. cstt|g|_dSN)superr__init___namesself __class__=/opt/hc_python/lib/python3.8/site-packages/aenum/_constant.pyrszNamedConstantDict.__init__cst|rtd|fn^t|r"nT||jkr Block attempts to reassign NamedConstant attributes. cKstSr)r)metaclsclsbaseskwdsrrr __prepare__4szNamedConstantMeta.__prepare__c st|tkr0|}t}|D]\}}|||<qi}i}|D]6\} } | |jkr^| || <q@nt| trn| j} | || <q@tt | ||||} i| _ i| _ |D] \} } | | | | } | | j | <q| Sr) typedictritemsr rZ nonmemberrrr__new___named_constant_cache_ _members_) rrr ZclsdictZ original_dictkvZnewdict constantsnameobjZnewclsZnew_kr rrr&8s*      zNamedConstantMeta.__new__cCsdS)NTrrrrr__bool__OszNamedConstantMeta.__bool__csH|j|}tdk r4t|tr4td|jj|jftt | |dS)Nzcannot delete constant <%s.%s>) __dict__getrrAttributeErrorr r_name_rr __delattr__)rattrcur_objr rrr4Rs zNamedConstantMeta.__delattr__cCsdd|jDS)Ncss|] }|VqdSrr.0r)rrr Ysz-NamedConstantMeta.__iter__..)r(valuesr.rrr__iter__XszNamedConstantMeta.__iter__cCsddt|jDS)Ncss|] }|VqdSrrr7rrrr9\sz1NamedConstantMeta.__reversed__..)reversedr(r:r.rrr __reversed__[szNamedConstantMeta.__reversed__cCs t|jSr)lenr(r.rrr__len__^szNamedConstantMeta.__len__csJ|j|}tdk r4t|tr4td|jj|jftt | ||dS)z3Block attempts to reassign NamedConstants. Ncannot rebind constant <%s.%s>) r0r1rrr2r rr3rr __setattr__)rr,rr6r rrrAcs zNamedConstantMeta.__setattr__)rrrr classmethodr"r&r/r4r;r=r? __nonzero__rArrrr rr/s   rzPNamedConstants protection. Derive from this class to lock NamedConstants. )r$docnsc Cs&|dkrN|}|jD]$\}}t||r|j|kr|Sqtd||jf|j|}t|tr|td|j j|j fnt|t r|p|j }|j }|j }t|tr|j}t|}|j|}|dkrt|j|t|fi}||jt|<|||}||_ ||_||_ ||j|<|||||S)Nz%r does not exist in %rr@)r0r%r_value_rrr1rr2r r3rrrr#r'r&r(rA) rr,rrDr-r6rZ actual_typeZ value_typerrrr&qs6         r&cCsd|jj|j|jfS)Nz <%s.%s: %r>)r rr3rFr rrr__repr__s rGcCst|j|jffSr)getattrr r3)r protorrr __reduce_ex__srJ)NN)Z_common__all__rr$rr#rZ _Addendumr"objectglobalsZ constant_dictr&rGrJresolverrrrrs($<