o bc@sddlZddlmZmZgdZddZddZdd Zd d Zd d Z e Z GdddZ Gddde ZdZGdddeZGdddedZGdddeeZddZGdddeZGdddeeZdd Zd!d"Zd#d$ZdS)%N)MappingProxyTypeDynamicClassAttribute)EnumMetaEnumIntEnumFlagIntFlagautouniquecCs t|dpt|dpt|dS)N__get____set__ __delete__)hasattr)objre/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/enum.py_is_descriptor s  rcCsN t|dko&|dd|ddkodkno&|ddko&|ddkS)NZ___lennamerrr _is_dunders &  rcCsN t|dko&|d|dkodkno&|dddko&|dddkS)Nrrrrrrrrr _is_sunder!s rcCs^d|f}t|}t||kr-||r-|||ddgkr-|ddks+|ddkr-dSdS)Nz_%s__rrrrTF)r startswith)Zcls_namerpatternZpat_lenrrr _is_private,s  r"cCs dd}||_d|_dS)NcSs td|)Nz%r cannot be pickled) TypeErrorselfZprotorrr_break_on_call_reduce>s z6_make_class_unpicklable.._break_on_call_reducez ) __reduce_ex__ __module__)clsr&rrr_make_class_unpicklable:s r*c@seZdZ eZdS)r N)__name__r( __qualname__ _auto_nullvaluerrrrr Dsr cs*eZdZ fddZfddZZS) _EnumDictcs&tg|_g|_g|_d|_dS)NF)super__init__ _member_names _last_values_ignore _auto_calledr% __class__rrr1Rs  z_EnumDict.__init__cs t|j|rddl}|jd|ftddt|r`|dvr"td|dkr4|jr-tdt |d |n|d kr_t |t rF| d d  }nt|}||_t|t|j@}|r_td |fn[t|rk|dkrjd}nP||jvrvtd|||jvr|n?t|s||vrtd|||ft |tr|jtkr||dt|j|jdd|_d|_|j}|j||j|t||dS)Nrz@private variables, such as %r, will be normal attributes in 3.11r stacklevel)_order__create_pseudo_member__generate_next_value_ _missing__ignore_z(_names_ are reserved for future Enum user=z4_generate_next_value_ must be defined before members_generate_next_valuer?, z-_ignore_ cannot specify already set names: %rZ __order__r;zAttempted to reuse key: %rz%r already defined as: %rrT)r" _cls_namewarningswarnDeprecationWarningr ValueErrorr5r#setattr isinstancestrreplacesplitlistr4setr2rrr r.r-r@rr3appendr0 __setitem__)r%keyr.rDZalreadyr7rrrPYsl          z_EnumDict.__setitem__)r+r(r,r1rP __classcell__rrr7rr/Ks r/cseZdZ eddZfddZddZd,ddddd d d Zd d ZfddZ ddZ ddZ ddZ ddZ ddZeddZddZddZfd d!Zddddd d"d#Zd,d$d%Zed&d'Zed(d)Zed*d+ZZS)-rcKsD|||t}||_|||\}}|dur t|dd|d<|S)Nr=)_check_for_existing_membersr/rC _get_mixins_getattr)metaclsr)baseskwdsZ enum_dict member_type first_enumrrr __prepare__s zEnumMeta.__prepare__c sdgdd}|D]}|dq|||\}||\}} } fddjD} jD]} | =q7dd} t| ddh@}|rWtdd |d vr_d d <t j |||fi|}g|_ i|_ |_d d |D}i|_d vrՈturd}tfdd|Dsdvrt|n6d}|D]+}|jD]turqtfdd|Drd}n djvrd}nq|durnq|rt|jD]}| |}t|ts|f}n|}tur|f}| s||}t|ds||_n||g|R}t|dstur||_n||_|j}||_||_|j||j D]\} }|j|jkr=|}nq.|j |||vrPt|||||j |<z||j|<WqtyfYqwdD]+} | vrrqit || }t | d}t || d}|dur||urt|| |qit!dur| r||_"t!j |_ | durt| t#r| $dd%} | |j krtd|S)Nr?csi|]}||qSrr).0k) classdictrr sz$EnumMeta.__new__..r;mrozInvalid enum member name: {0}rA__doc__zAn enumeration.cSs.h|]}|jD] \}}t|tr |q qSr)__dict__itemsrIr)r\cr]vrrr sz#EnumMeta.__new__..r')Z__getnewargs_ex____getnewargs__r' __reduce__c3|]}|jvVqdSNrcr\m)rYrr z#EnumMeta.__new__..__new__c3rjrkrlrm)baserrrorpFT_value_)__repr____str__ __format__r'rBz#member order does not match _order_)& setdefaultrOpoprT _find_new_r2rNrGformatjoinr0rq_member_names_ _member_map_ _member_type_r`_value2member_map_objectanyr*__mro__rcrItuplerrs_name_ __objclass__r1rdrHr#rUr__new_member__rJrKrL)rVr)rWr^rXignorerQrZrqsave_newuse_argsZ enum_membersrr;Z invalid_names enum_classZdynamic_attributesmethodsZsabotagechain member_namer.argsZ enum_memberZcanonical_memberZ class_methodZ obj_methodZ enum_methodr7)rrr^rYrrqs                           zEnumMeta.__new__cCs dS)NTrr6rrr__bool__aszEnumMeta.__bool__NrmodulequalnametypestartcCs, |dur |||S|j||||||dS)Nr)rq_create_)r)r.namesrrrrrrr__call__gs zEnumMeta.__call__cCsRt|tsddl}|jdtddtdt|j|jjft||o(|j |j vS)Nrzpin 3.12 __contains__ will no longer raise TypeError, but will return True if obj is a member or a member's valuerr93unsupported operand type(s) for 'in': '%s' and '%s') rIrrDrErFr#rr,r8rr})r)rrDrrr __contains__s zEnumMeta.__contains__cs(||jvr td|jt|dS)Nz%s: cannot delete Enum member.)r}AttributeErrorr+r0 __delattr__)r)attrr7rrrs zEnumMeta.__delattr__cCsgd|jS)N)r8rb __members__r(r|r6rrr__dir__szEnumMeta.__dir__cCs8 t|r t|z|j|WStyt|dwrk)rrr}KeyErrorr)rrrr __getattr__s   zEnumMeta.__getattr__cCs |j|Srkr}rrrr __getitem__ zEnumMeta.__getitem__cs fddjDS)Nc3|]}j|VqdSrkrr\rr)rrrorpz$EnumMeta.__iter__..rrrrr__iter__szEnumMeta.__iter__cC t|jSrk)rr|rrrr__len__rzEnumMeta.__len__cCs t|jSrk)rr}rrrrrs zEnumMeta.__members__cCs d|jS)Nz )r+rrrrrtrzEnumMeta.__repr__cs fddtjDS)Nc3rrkrrrrrrorpz(EnumMeta.__reversed__..)reversedr|rrrr __reversed__szEnumMeta.__reversed__cs2 |jdi}||vrtdt||dS)Nr}zCannot reassign members.)rcgetrr0 __setattr__)r)rr.Z member_mapr7rrrs zEnumMeta.__setattr__c Csh |j}|dur |fn||f}|||\} } |||} t|tr*|dd}t|ttfrb|rbt|dtrb|g} }g} t | D]\}}| |||| dd}| || ||fqE|D]}t|trs|||}}n|\}}|| |<qd| |||| }|durz t djd}Wn tttfyYnw|durt|n||_|dur||_|S)NrArBrrr+)r8rTr[rIrJrKrLrrM enumerater=rOrqsys _getframe f_globalsrrGrr*r(r,)r) class_namerrrrrrVrWrrZr^Zoriginal_names last_valuescountrr.itemr member_valuerrrrrs@         zEnumMeta._create_cs ttj|}|rt|}n|}fdd|D}z |jdddWnty7|jdddYnw||||d}t|_||j |||<|S)Ncs g|] \}}|r||fqSrr)r\rr.filterrr )s z&EnumMeta._convert_..cSs|d|dfS)Nrrrtrrr/sz$EnumMeta._convert_..)rQcSs|dSNrrrrrrr2s)r) varsrmodulesrdsortr#_reduce_ex_by_namer'updater)r)rrrsourceZmodule_globalsmembersrrr _convert_s$    zEnumMeta._convert_cCs<|D]}|jD]}t|tr|jrtd||jfqqdS)Nz %s: cannot extend enumeration %r)r issubclassrr|r#r+)rrWrrrrrrrS9s z$EnumMeta._check_for_existing_memberscsV |sttfSfdd}|d}t|tstd||pt}|jr'td||fS)Ncst}|D]:}d}|jD]2}|turq t|tr&|jtur%||jnq d|jvr:t|tr1q ||p6|n|p=|}q qt|dkrNt d|f|rT| SdS)Nrqrz%r: too many data types: %r) rNrrrrr~addrcrr#rx)rWZ data_typesr candidaterrrrr_find_data_typeNs.        z.EnumMeta._get_mixins_.._find_data_typerzZnew enumerations should be created as `EnumName([mixin_type, ...] [data_type,] enum_type)`zCannot extend enumerations)rrrr#r|)rrWrrZrYrrrrTCs   zEnumMeta._get_mixins_c Cs |dd}|du}|dur9dD]$}||fD]}t||d}|ddjtjtjhvr.|}nq|dur5nqtj}|tjurAd}nd}|||fS)Nrq)rrqFT)rrUrqrr) r^rYrZrqrmethodZpossibletargetrrrrryrs0     zEnumMeta._find_new_rk)r+r(r, classmethodr[rqrrrrrrrrrpropertyrrtrrrr staticmethodrSrTryrRrrr7rrs8  .%     5!  .rc@sreZdZ ddZddZeddZddZd d Zd d Z d dZ ddZ ddZ e ddZe ddZdS)rc Cst||ur|Sz|j|WStyYnty2|jD] }|j|kr/|YSq"Ynwz d}||}WntyR}z |}d}WYd}~nd}~wwz6t ||r`|Wd}d}St d||j f}|durs|durs||durtd|j |f}t |t s||_ |d}d}w)N%r is not a valid %szDerror in %s._missing_: returned %r instead of None or a valid member)rrrr#r}valuesrsr> ExceptionrIrGr,r+ __context__)r)r.memberexcresulteZve_excrrrrqsP        z Enum.__new__c Cs4 t|D]}z|dWStyYqw|SNr)rr#)rrrr last_valuerrrr=s  zEnum._generate_next_value_cCsdSrkr)r)r.rrrr>szEnum._missing_cCsd|jj|j|jfS)N <%s.%s: %r>)r8r+rrsr6rrrrtsz Enum.__repr__cCsd|jj|jfS)N%s.%s)r8r+rr6rrrrusz Enum.__str__cs6 fddjDddjD}gd|S)Ncs2g|]}|jD]}|ddkr|jvr|qqSrr)rcr})r\r)rnr6rrrsz Enum.__dir__..cSsg|] }|ddkr|qSrrrmrrrr)r8rbr()r8r`rc)r%Zadded_behaviorrr6rrs  z Enum.__dir__cCsL t|jtjtjfv}|jtus|rt}t|}n|j}|j}|||Srk) rrurrr~rrJrsrv)r% format_specZstr_overriddenr)valrrrrvs  zEnum.__format__cCrrk)hashrr6rrr__hash__rz Enum.__hash__cCs|j|jffSrkr8rsr$rrrr'szEnum.__reduce_ex__cC |jSrk)rr6rrrrz Enum.namecCrrkrsr6rrrr.!rz Enum.valueN)r+r(r,rqr=rr>rtrurrvrr'rrr.rrrrrs .   r) metaclassc@s eZdZdS)rN)r+r(r,rrrrr'srcC|jSrkrr$rrrr+src@sneZdZ ddZeddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZdS)rc CsZ |s |dur |SdSt|D]}zt|}Wnty&td|dwd|dS)NrzInvalid Flag value: %rr)r _high_bitrr#)rrrrrZhigh_bitrrrr=3s   zFlag._generate_next_value_cCs0 |}|dkr |}||}|dkr|}|Sr)r<)r)r.Zoriginal_valueZpossible_memberrrrr>Fs zFlag._missing_cCsd |j|d}|dur0t||\}}|rtd||jft|}d|_||_|j ||}|SNr) rr _decomposerGr,rrqrrsrw)r)r. pseudo_memberr extra_flagsrrrr<Ss zFlag._create_pseudo_member_cCs: t||jstdt|j|jjf|j|j@|jkS)Nr)rIr8r#rr,rsr%otherrrrrgs zFlag.__contains__cCsV|j}|jdurd|j|j|jfSt||j\}}d|jddd|D|jfS)Nr|cSg|] }t|jp |jqSrrJrrsrmrrrrxrz!Flag.__repr__..)r8rr+rsrr{r%r)r uncoveredrrrrtqs z Flag.__repr__cCs||j}|jdurd|j|jfSt||j\}}t|dkr/|djdur/d|j|djfSd|jddd|DfS)Nrrrz%s.%rrcSrrrrmrrrrrz Flag.__str__..)r8rr+rrsrr{rrrrru|s z Flag.__str__cCrrk)boolrsr6rrrrrz Flag.__bool__cCs"t||jstS||j|jBSrkrIr8NotImplementedrsrrrr__or__ z Flag.__or__cCs"t||jstS||j|j@Srkrrrrr__and__rz Flag.__and__cCs"t||jstS||j|jASrkrrrrr__xor__rz Flag.__xor__cCsNt|j|j\}}|d}|jD]}||vr!|j|j@s!||B}q||Sr)rr8rs)r%rrZinvertedrnrrr __invert__s   zFlag.__invert__N)r+r(r,r=rr>r<rrtrurrrrrrrrrr.s      rc@sReZdZ eddZeddZddZddZd d ZeZ eZ eZ d d Z d S)rcCs, t|tstd||jf||}|Sr)rIintrGr,r<)r)r.Z new_memberrrrr>s   zIntFlag._missing_cCs |j|d}|durV|g}t||\}}|rr<rrr__ror____rand____rxor__rrrrrrs    rcCs |dSr) bit_length)r.rrrrs rcCs` g}|jD]\}}||jkr|||jfq|r.ddd|D}td||f|S)Nz, cSsg|] \}}d||fqS)z%s -> %sr)r\aliasrrrrrrzunique..z duplicate values found in %r: %s)rrdrrOr{rG)Z enumerationZ duplicatesrrZ alias_detailsrrrr s  r c Cs |}|dk}g}|D]}|j}|r"||@|kr"||||M}q |sH|}|rHdt|}||jvrA||j|||M}||M}|s)|sW||jvrW||j||jddddt|dkrr|dj|krr|d||fS)NrrcSrrkr)rnrrrrsz_decompose..T)rQreverser)r.rOrrrrrx) Zflagr.Z not_coveredZnegativerrrZtmprrrrrs2       r)rtypesrr__all__rrrr"r*rr-r dictr/rrrrrrrrrr rrrrrs4    TvI