Qf>ddlZddlZddlmZmZddlmZddl m Z gdZ dxZ xZ xZxZZGddeZGdd eZd Zd Zd Zd ZdZdZdZdZdZdDdZdZGddZeZGddZ e Z GddZ!GddeZ"GddZ#Gdd e$Z%Gd!d"e&Z'e'Z(Gd#d$e'%Z Gd&d'e ZGd(d)e)eZ*Gd*d+e+eZ,d,Z-e-Z.d-Z/Gd.d/e,Z0e0\Z1Z2ZZ3Gd0d1e e12Z Gd3d4e)ee e32Z4d5Z5d6Z6d7Z7d8Z8d9Z9d:Z:dEd;Z;e fddd<d=Z<ed?Z=e=\Z>Z?Z@Gd@dAZAdBZBdDdd2dCZCe*e,e4fZy)FN)MappingProxyTypeDynamicClassAttribute)or_)reduce)EnumTypeEnumMetaEnumIntEnumStrEnumFlagIntFlagReprEnumautouniquepropertyverifymember nonmember FlagBoundarySTRICTCONFORMEJECTKEEPglobal_flag_reprglobal_enum_repr global_str global_enum EnumCheck CONTINUOUS NAMED_FLAGSUNIQUEpickle_by_global_namepickle_by_enum_nameceZdZdZdZy)rzK Protects item from becoming an Enum member during class creation. c||_yNvalueselfr(s +/opt/alt/python312/lib64/python3.12/enum.py__init__znonmember.__init__  N__name__ __module__ __qualname____doc__r,r.r+rr r.rceZdZdZdZy)rzE Forces item to become an Enum member during class creation. c||_yr&r'r)s r+r,zmember.__init__#r-r.Nr/r4r.r+rrr5r.rcRt|dxst|dxs t|dS)z? Returns True if obj is a descriptor, False otherwise. __get____set__ __delete__)hasattr)objs r+_is_descriptorr>&s1 C # ' C # ' C &r.cvt|dkDxr*|dd|ddcxk(xrdk(ncxr|ddk7xr|ddk7S)z= Returns True if a __dunder__ name, False otherwise. N___lennames r+ _is_dunderrJ0sT IM  !HRS )T )  GsN  HO r.cvt|dkDxr*|d|dcxk(xrdk(ncxr|dddk7xr|dddk7S)z; Returns True if a _sunder_ name, False otherwise. rArrDrBrFrHs r+ _is_sunderrN;sV IM  GtBx &3 &  1I   BK3  r.ct|tsyt|dd}|dzt|ddz}d|z}||k(xs|j|S)NFr2.r0) isinstancetypegetattrendswith)cls_namer=qualname s_pattern e_patterns r+_is_internal_classrZFsX c4 sNB/H3j"!==IiI y @H$5$5i$@@r.cd|d}t|}t||kDr.|j|r|||dzdgk7r|ddk7s|ddk7ryy)NrDrCrMrLrBTF)rG startswith)rVrIpatternpat_lens r+ _is_privater_Os[!$G'lG I (WWQY'C50bSDHOr.c(|dk(ry||dz z}|dk(S)z< True if only one bit set in num (should be an int) rFrMr4)nums r+_is_single_bitrb]s$ ax37NC !8Or.ctd}t|tr ||d<d|d<yt|d|t|ddy)z] Make the given obj un-picklable. obj should be either a dictionary, or an Enum ctd|z)Nz%r cannot be pickled) TypeErrorr*protos r+_break_on_call_reducez6_make_class_unpicklable.._break_on_call_reducels.566r. __reduce_ex__z r1N)rRdictsetattr)r=rhs r+_make_class_unpicklablerlfs> 7#t4O'L_&;<\;/r.c#K|}t|tr |j}|dkrtd|z|r||dzz}|||z}|ryyw)Nrz%r is not a positive integerrM)rRr r( ValueError)raoriginalbs r+_iter_bits_lsbrqus\H#tii Qw7(BCC C4!8  q s AA  A c*tt|Sr&)listrqr's r+show_flag_valuesrts u% &&r.c$d|jz}|dk\r*tj||zjddd}ntj||dz |zz }|dd}|dd}|t ||kr|d|z|z| d}|d |S) z Like built-in bin(), except negative values are represented in twos-compliment, and the leading bit always indicates sign (0=positive, 1=negative). >>> bin(10) '0b0 1010' >>> bin(~10) # ~10 is -11 '0b1 0101' rAr10rMNrL ) bit_lengthbltnsbinreplacerG)ramax_bitsceilingssigndigitss r+r|r|sC##%%G ax IIcGm $ , ,S#q 9 IIsdgkW44 5 Ra5D qrUF v; !2h)F2XIJ?FF ##r.c|jd}d}t|dD] \}}|dk7s nt|D] \}}|d||<dj|S)zM Like textwrap.dedent. Rewritten because we cannot import textwrap.  rryN)split enumeratejoin)textlinesblanksichjls r+_dedentrsk JJt E F58$2 9 %% 1QR5a! 99U r.ceZdZdZy) _not_givency)Nz r4r*s r+__repr__z_not_given.__repr__sr.Nr0r1r2rr4r.r+rrsr.rceZdZdZy) _auto_nullcy)Nrr4rs r+rz_auto_null.__repr__sr.Nrr4r.r+rrsr.rc eZdZdZefdZdZy)rzP Instances are replaced with an appropriate value in Enum class suites. c||_yr&r'r)s r+r,z auto.__init__r-r.c d|jzS)Nzauto(%r)r'rs r+rz auto.__repr__sDJJ&&r.N)r0r1r2r3rr,rr4r.r+rrs('r.rc6eZdZdZdZdZdZddZdZdZ dZ y)raI This is a descriptor, used to define attributes that act differently when accessed through an enum member and through an enum class. Instance access is the same as property(), but access to an attribute through the enum class will instead look in the class' _member_map_ for a corresponding enum member. Nc|2|j |jSt|d|j|j|j|S|jdk(r t |j |jS|jdk(r t |j|jS |j|jS#t$rt|d|jdwxYw)Nz has no attribute attrdesc) rAttributeErrorrIfget _attr_typerT _cls_type_value_ _member_map_KeyError)r*instance ownerclasss r+r9zproperty.__get__s  {{&{{"$4> J 99 99X& & __ &4>>4995 5 __ &8++TYY7 7 **4995 5  0:DIIF  s 1C %C/c|j|j||Std|jd|j)N cannot set attribute )fsetrclsnamerI)r*rr(s r+r:zproperty.__set__s: 99 99Xu- -7;||TYYO r.c|j|j|Std|jd|j)Nrz> cannot delete attribute )fdelrrrI)r*rs r+r;zproperty.__delete__s8 99 99X& &:>,, R r.c4||_|j|_yr&)rIr0r)r*rrIs r+ __set_name__zproperty.__set_name__s !** r.r&) r0r1r2r3rrrr9r:r;rr4r.r+rrs,FJI 2+r.rceZdZdZdZdZy) _proto_memberzW intermediate step for enum members between class execution and final creation c||_yr&r'r)s r+r,z_proto_member.__init__r-r.ct|||j}t|ts|f}n|}|jtur|f}|j s|j |}n|j |g|}t|ds/|jtur||_ n |j||_ |j}||_ ||_|j|t!|j"|_t&zt)|t&rjt|t*r5|xj,|zc_t/|r|xj0|zc_d|j,j3zdz |_ |j6|}d} d} d} |j@ddD]\} | jBjE|}|!t|tFtHfr|} | } d} n tK|r|} | xsd} | xs| } Yd} | } ^| rtG}||_&|jO||| d vrltQ| d d|_)tQ| d d|_*tQ| d d|_+tQ| d d|_,tQ| dd|_-tQ| dd|_.| |_/| |_0tc|||n tc|||||j8|< |j6je||y#t$r}td}||_ |d}~wwxYw#t$r?|j8j;D]\}} | j|k(s| }nt<YwxYw#t<$rt&t)|t&s|j"j?|nLt&Ft)|t&r6t|t*r&t/|r|j"j?|YYwxYw#t$r|jfj?|YywxYw)zR convert each quasi-member into an instance of the new enum class rz/_value_ not set in __new__, unable to create itNrArMenumrr)rrrr9rr:rr;)4delattrr(rRtuple _member_type_ _use_args_ _new_member_r<objectr Exceptionre __cause___name_ __objclass__r,rG_member_names_ _sort_order_r issubclassint _flag_mask_rb_singles_mask_rz _all_bits__value2member_map_ritemsrappend__mro____dict__getrrr>rrrTr_getr_setr_delrrrk setdefault_unhashable_values_)r* enum_class member_namer(args enum_memberexcnew_excrIcanonical_memberfound_descriptordescriptor_type class_typebaserredirects r+rz_proto_member.__set_name__s  K( %'9DD  # #u ,8D$$$11*=K1*11*DtDK{I.''61&+ #"*B**B*BD*IK'##( #-   d##&z'@'@#A    :t <%%&&%/&!%(--6-$%:+A+A*M*M*O$PST$TJ ! > #(;;EB 4  &&qr*D==$$[1DdX/D$EF'+$!%J&,O#D)'+$&5&?O!+!3tJ&,O!%J+ zH)HO  ! !*k :/1 '(8&$ G '(8)T J '(8&$ G '(8)T J '(8&$ G '(8, M "1H !+H  J X 6 J [ 9/:  , 9  ) ) 4 4UK Hy!"'MG),G%!M "2 #.8.E.E.K.K.M*D*'//58&6 /N #N  # >L%j$7))00=$":t4"5#.&u-))00=! >z 9  * * 1 1% 8 9s[K#5LO!# L,LL8M M MMMBOO!$PPN)r0r1r2r3r,rr4r.r+rrsw9r.rc2eZdZdZfdZfdZdZxZS) _EnumDictz Track enum member order and ensure member names are not reused. EnumType will use the names found in self._member_names as the enumeration member names. cZt|i|_g|_g|_d|_y)NF)superr, _member_names _last_values_ignore _auto_called)r* __class__s r+r,z_EnumDict.__init__s-  !r.c @t|j|rddl}|jdtdt |j|rnt |r|dvrtd|d|d k(rD|jr td t|tr |jn|}t|d |nH|d k(rBt|tr!|jd dj!}n t#|}||_t'|t'|j(z}|rtd|t+|r |dk(rd}n||j(vrt|d||||j$vrnt|t,r|j.}nit1|rn\||vrt|d||t|t2r |j.}d}d}t|t4rd}|f}t|t6rt9d|Drg}t;|} |D]} t| t4r|d}| j.t<k(r@|j?|dtA|j(|jBdd| _d|_| j.} |jBjE| |jE| |r|d}n | |}d|j(|<|r|jBjE|tF |||y#t$r| |}YMwxYw)z Changes anything not dundered or not a descriptor. If an enum member name is used twice, an error is raised; duplicate values are not checked for. Single underscore (sunder) names are reserved. rNzzIn 3.13 classes created inside an enum will not become a member. Use the `member` decorator to keep the current behavior.rA stacklevel)_order__generate_next_value__numeric_repr_ _missing__ignore_ _iter_member__iter_member_by_value__iter_member_by_def_z_sunder_ names, such as z", are reserved for future Enum userz4_generate_next_value_ must be defined before members_generate_next_valuer,ryz+_ignore_ cannot specify already set names: __order__rz already defined as TFc3<K|]}t|tywr&)rRr).0vs r+ z(_EnumDict.__setitem__..s/SU 1d0CUsrM)%rZ _cls_namewarningswarnDeprecationWarningr_rNrnrrerR staticmethod__func__rkstrr}rrsrsetrrJrr(r>rrranyrSrrrGrrr __setitem__) r*keyr(r_gnvalreadynon_auto_storesingle auto_valuedtrrs r+rz_EnumDict.__setitem__s dnne 4  MMO&   t~~s +  _ !"--$$#$Z[[)3E<)Hu~~e4d; "eS)!MM#c288:E KE$ e*s4+=+='>>$&*_k! D&& &#tCyIJ J DLL  y )KKE E "  d{c49 MNNE6* !NF%& %'C/SU/S,S! KA!!T*).77j0&*&?&?$'C0B0B,CTEVEVWXEY'&AG15D-GG))003&&q)'NE0 !+'+D  s #!!((/ C' %0 !;0sL LLc |jD] }||||<  |jD] \}}|||< y#t$r|D] \}}|||< Y8wxYwr&)keysrr)r*members more_membersrIr(s r+updatez_EnumDict.updatesn # $T]T ' (--/KD%DJ0 #& e"T  ' #s>AA)r0r1r2r3r,rr __classcell__rs@r+rrxs "i(Vr.rc.eZdZdZedZdddfd ZdZefdddddd d Z d Z fd Z d Z dZ dZdZej"dZdZdZfdZdddddd dZdddddZedZedZedZedZedZxZS)rz Metaclass for Enum c |j||t}||_|j||\}}|t |dd|d<|S)Nr)_check_for_existing_members_rr _get_mixins_rT)metaclsclsbaseskwds enum_dict member_type first_enums r+ __prepare__zEnumType.__prepare__s` ,,S%8K ! ")"6"6sE"B Z  !18 72I- .r.NFboundary_simplec $ |rt |||||fi|S|jdgjd|d}|D]}|j |d|j } t | ddhz} | r$tddjd| Dz|j dd} |jd} | t| tur t| } t|j}| | |d<|j||\} }|j|| |\}}}||d <||d <| D]}||}t!|||<g|d <i|d <i|d <g|d<| |d<|j#|||d<|xs t%|dd|d<d|d<d|d<d|d<d|d< d}t |||||fi|}||j1|j3j4t6t6|vr{| t8ur t;dd|vr | j<|_|j<|d<d|vr@| j>}|t8j>ur | j@}||_|j>|d<dD]O}||vst%||}t%||}t%t8|}t%| |}|||fvsCtC|||QtD>tG|tDr.dD])}||vst%tD|}tC||||||<+tH|r||_%tHj|_| 0tM| t(r | jOddjQ} tD|dk7stDMtG|tDs=tS|dtS|dtS|dtS|dtS|dntDtG|tDro|Dcgc]}|jT}}|tW|k7r|jX|_-| r5| Dcgc]*}||j\vst_||jTr|,} }| rc| Dcgc].}||j\vs||j\vr||j`vr|0} }| |j`k7rt;d|j`d| |S#t&$rS}t|t)|}|j*|_|j,|_|j.}Yd}~Fd}~wwxYwcc}wcc}wcc}w) NrmrorPzinvalid enum member name(s) %src32K|]}t|ywr&)repr)rns r+rz#EnumType.__new__..&s%D*+  15I- .#*"6"6sE"B Z&-&8&8; '#8%, .!"* ,!DdOE+E2IdO! ') "#$& .!*, &'+- '(%0 /"$+$<$(> %*4*?*? ,' )$,,V^^+)11F%+ "'1'9'9 )$JD9$%j$7 &z48 ' 5 #*;#= $4m#DDJk:K   :t < y(")$"5KJk:&1IdO  ,3 )!%J   '3'!//#s399; #Jz4,H J - J . J 0 1 J - J -  *Z">.89j199jK9f[11+5+J+J (")!(AJ$;$;;~jYZmNcNc?d!( %$!8!88j555!z?X?X:X $ *333%44g? s !$q'#a&/CKKCMmmCOB !z: s+ R$T /T3T $ T-AS;;Tcy)z6 classes/types should always be True. Tr4rs r+__bool__zEnumType.__bool__sr.rM)modulerWrSstartrc |jr!|tur||f|z}|j||S|tur|t|d|j ||turdn||||||S)ab Either returns an existing member, or creates a new enum class. This method is used both when an enum class is given a value to match to an enumeration member (i.e. Color(3)) and for the functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')). The value lookup branch is chosen if the enum is final. When used for the functional API: `value` will be the name of the new class. `names` should be either a string of white-space/comma delimited names (values will start at `start`), or an iterator/mapping of name, value pairs. `module` should be set to the module this class is being created in; if it is not set, an attempt to find that module will be made, but if it fails the class will not be picklable. `qualname` should be set to the actual location this class can be found at in its module; by default it is set to the global scope. If this is not correct, unpickling will fail in some circumstances. `type`, if set, will be mixed in as the first base class. NzM has no members; specify `names=()` if you meant to create a new, empty, enum) class_namenamesrOrWrSrPr)rrr3re_create_) rr(rSrOrWrSrPrvaluess r+__call__zEnumType.__call__s6   J&/;;sE* * J 4<ehi || #z1du!! r.cXt||ry||jvxs||jvS)zReturn True if `value` is in `cls`. `value` is in `cls` if: 1) `value` is a member of `cls`, or 2) `value` is the value of one of the `cls`'s members. T)rRrrrr(s r+ __contains__zEnumType.__contains__s2 eS !...R%3;R;R2RRr.cv||jvrt|jd|dt||y)Nz cannot delete member rQ)rrr0r __delattr__)rrrs r+r[zEnumType.__delattr__s5 3## # #,,PT!UV V D!r.cxtgd|jz}|jtjur|j d|j tj ur|j d|jtur t|Sttt|j|zS)N) rrYr3 __getitem____iter____len__ __members__r1r0r2r3__init_subclass__) rrrrr3addrarr;dir)r interestings r+__dir__zEnumType.__dir__s $$ %    6>> 1 OOI &  (@(@ @ OO/ 0    &+& &#c#"3"345 CD Dr.c |j|S)z4 Return the member matching `name`. r)rrIs r+r]zEnumType.__getitem__*s%%r.c.fdjDS)z5 Return members in definition order. c3<K|]}j|ywr&rgrrIrs r+rz$EnumType.__iter__..4sF3E4  &3ErrMs`r+r^zEnumType.__iter__0sG33E3EFFr.c,t|jS)z; Return the number of members (no aliases) )rGrrMs r+r_zEnumType.__len__6s3%%&&r.c,t|jS)z Returns a mapping of member name->value. This mapping lists all enum members, including aliases. Note that this is a read-only view of the internal mapping. )rrrMs r+r`zEnumType.__members__<s  0 011r.cjtt|trd|jzSd|jzS)Nz z )r rr0rMs r+rzEnumType.__repr__Fs/   3 5- -- -r.c@fdtjDS)z= Return members in reverse definition order. c3<K|]}j|ywr&rgrjs r+rz(EnumType.__reversed__..PsP3O4  &3Ork)reversedrrMs`r+ __reversed__zEnumType.__reversed__LsQ8C value pairs. Nrryrr4rAr0r1r2r)rrrrRrr}rrrsrrrsys_getframemodulenamer _getframe f_globalsrnrrlr3)rrRrSrOrWrSrPrrrrDrr<original_names last_valuescountrIr(itemr member_values r+rTzEnumType._create__s--<dC[((U; :'' E:  eS !MM#s+113E eeT] +*U1Xs:S$)2ENK(8 t"88ue[YZ^\""5) dE]+ 9 =ED$$,0%+\ ,0) \%1Ik "  > 003 > #I .&,Il #  (0In %w E9xXX"  ]]1-77 CF& H=  s6E!! F++"F F+F%"F+$F%%F+*F+)r as_globalcrtj|j}|r |j}n|}|jDcgc]\}}||r||f} }} | j d| D cic] } | d| d } } || d<t tf| } t||xst| }|r t|n@tj|jjj|j|||<|Scc}}w#t $r| j dYwxYwcc} w)z[ Create a new Enum subclass that replaces a collection of global constants c|d|dfSNrMrr4r s r+z$EnumType._convert_..s!ad|r.rc |dSNrr4rs r+rz$EnumType._convert_..sqtr.rrMr1)etyper)rymodulesrrsortrerSr _simple_enumrrr1rr`) rrIrOfiltersourcerrmodule_globalsr(r r bodytmp_clss r+ _convert_zEnumType._convert_s/V,55 __F#F $*<<>!#1KD%$<u #1 ! - LL3L 4%,,Gq!ad G,#\tfZ.@lx/?4@I    KK ' 0 0 7 7 H"t '! - LL^L , --sD D3D4D10D1c|D]A}|jD]0}t|ts|js!t d|d|Cy)Nrz> cannot extend )rrRrrremclsrRrchainrs r+rz%EnumType._check_for_existing_members_sCE dH-$2E2E#)41&r.c|s ttfS|d}t|ts t d|j ||xst}||fS)z Returns the type for creating enum members, and the first inherited enum class. bases: the tuple of bases that was given to __new__ rLzZnew enumerations should be created as `EnumName([mixin_type, ...] [data_type,] enum_type)`)rr rRrre_find_data_type_)rrRrrrs r+rzEnumType._get_mixins_s]4< 2Y *h/KL L++J>H& J&&r.cF|D]}|jD]}|tur t|tr|jccSd|j vs;d|j vr1d|j vr#|j dj r tccS|j dccSy)Nr__dataclass_fields____dataclass_params__)rrrRrr&rr#_dataclass_reprrs r+r6zEnumType._find_data_repr_sE 6>h/,,,4==03dmmC 6$-- G $ .D E J J..#}}Z88!&$r.ct}t}|D]}d}|jD]}|j||turt |t r0|j tus@|j|j nd|jvsd|jvr|j|xs||xs|}t|dkDrtd|d||r|jSy)Nr3rrMztoo many data types for : ) rrrbrrRrrrrGrer4)rrRr data_types base_chainr candidaters r+rzEnumType._find_data_type_sU U EI t$6>h/))7"t'9'9:$--/3IT]]3ZNN9#45 ) 1TI& z?Q  JWX X >># #r.c`|jdd}|duxr|du}|cdD]N}||fD]A}t||d}|ddjtjtjhvs?|}n|Nntj}|"|tjtjfvrd} nd} ||| fS)a Returns the __new__ to be used for creating the enum members. classdict: the class dictionary given to __new__ member_type: the data type whose __new__ will be used by default first_enum: enumeration to check for an overriding __new__ r3N)r:r3FT)rrTr3rr ) rr<rrr3r@rDpossibletargetrAs r+r5zEnumType._find_new_ s-- 40T)AgT.A ?8!,j 9H$Xvt>,J!JHH(**r.r&)r0r1r2r3 classmethodrr3rNrrVrYr[rer]r^r_r{rr`rrsrurTrrrr6rr5rrs@r+rrs   =A%~@ $..tdY]efqu.` S"E$& G '  ^^22. Q )48$TYZei6Yp$dV[$L''$*4*+*+r.rceZdZdZedZdZdZedZ edZ dZ dZ d Z d Zd Zd Zd ZdZedZedZy)r a Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. c|jryy)Nz (*values)z\(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)rlrMs r+ __signature__zEnum.__signature__bs   qr.ct||ur|S |j|S#t$rYnBt$r7|jj D]}|j |k(s|ccYSYnwxYw|jstd|z d}|j|}n#t$r}|}d}Yd}~nd}~wwxYw t||r|d}d}St8t|tr(|jturt|tr|d}d}St|d|j }||||td|j"d|d}t|ts||_|#d}d}wxYw)Nz%r has no members defined is not a valid z error in z._missing_: returned z" instead of None or a valid member)rSrrrerrUrrrrRr rr'rrrnr2r0r7)rr(rrresultrBve_excs r+r3z Enum.__new__isx ;# L "))%0 0   "**113>>U*!M4 "7#=> > C]]5)F CF  &#&(CF'$C)>%/Jvs4KCF$eSEUEU$VW>ck L[#"||V5C"#z2&,CO CFsQ A*4A* A*&A*)A*B B3%B..B37 E 9EAEE$cyr&r4)r*rrs r+r,z Enum.__init__s r.c|s|S |d}|j||dk(r|dzSt#t$rIddl}|jdtdt |D]} |dzccYS#t$rYwxYw|cYSwxYw)z Generate the next value when not given. name: the name of the member start: the initial start value or None count: the number of existing members last_values: the list of values assigned rLrMrNzIn 3.13 the default `auto()`/`_generate_next_value_` will require all values to be sortable and support adding +1 and the value returned will be the largest value in the enum incremented by 1rxr)rrerrrrr)rIrPrr~lastrrs r+rzEnum._generate_next_value_sL r?D    {2&ax    MMd&   k*q5L + L s7!..3B"A+&B+ A74B6A77B?Bcyr&r4rXs r+rzEnum._missing_sr.c|jjxst}d|jjd|jd||j dS)N)rr&r#r0rr)r*v_reprs r+rz Enum.__repr__s:,,4 $ 7 7fT\\FZ[[r.cL|jjd|jS)NrQ)rr0rrs r+r*z Enum.__str__s..114;;AAr.ct}|jjturttj |}t |dgD]+}|ddk7s ||j vs|j|-|jjD]}|jjD]|\}}|ddk(rt|tr>|j||j vr|j|K|j|]||j vsl|j|~ttgd|z}|S)zJ Returns public methods and other interesting attributes. rrrD)rr3__eq____hash__r1)rrrrrerTrrbr!rrrRrrdiscardr;)r*rdrIrr=rSs r+rez Enum.__dir__s$e >> ' 'v 5fnnT23KD*b1DAw#~$d.?.?"?%2>>%%'C \\//1 c7c>c8,xx+t4;L;L/L#-$++D1!2!22OOD)2(PQ r.c@tjt||Sr&)rr))r* format_specs r+r)zEnum.__format__s~~c$i55r.c,t|jSr&)hashrrs r+rz Enum.__hash__sDKK  r.c4|j|jffSr&)rrrfs r+rizEnum.__reduce_ex__s~~ ///r.c|Sr&r4)r*memos r+ __deepcopy__zEnum.__deepcopy__ r.c|Sr&r4rs r+__copy__z Enum.__copy__rr.c|jS)zThe name of the Enum member.)rrs r+rIz Enum.names{{r.c|jS)zThe value of the Enum member.)rrs r+r(z Enum.value s||r.N)r0r1r2r3rrr3r,rrrrr*rer)rrirrrrIr(r4r.r+r r :s%Nrr 6p !!F\B:6!0r.r ) metaclassceZdZdZy)rzS Only changes the repr(), leaving str() and format() to the mixed-in type. Nr0r1r2r3r4r.r+rrr.rceZdZdZy)r z8 Enum where members are also (and must be) ints Nrr4r.r+r r rr.r c&eZdZdZdZedZy)r z; Enum where members are also (and must be) strings ct|dkDrtd|t|dk(r$t|dtst|ddt|dk\r$t|dtstd|dt|dk(r$t|dtstd|dzt|}tj ||}||_|S) z$values must already be of type `str`rxztoo many arguments for str(): rMrz is not a stringrAzencoding must be a string, not zerrors must be a string, not %r)rGrerRrr3r)rrUr(rs r+r3zStrEnum.__new__#s v;?&KL L v;! fQi-q DEE v;! fQi-vay STT v;! fQi- AVAY OPPV S%( r.c"|jS)zD Return the lower-cased version of the member name. )lower)rIrPrr~s r+rzStrEnum._generate_next_value_8s zz|r.N)r0r1r2r3r3rrr4r.r+r r s *r.r c|jSr&rHrfs r+r"r"@s 99r.c>t|j|jffSr&)rTrrrfs r+r#r#Es T^^T[[1 11r.cHeZdZdZeZeZeZeZy)ra control how out of range values are handled "strict" -> error is raised [default for Flag] "conform" -> extra bits are discarded "eject" -> lose flag status "keep" -> keep flag status and all bits [default for IntFlag] N) r0r1r2r3rrrrrr4r.r+rrIs%VFfG FE 6Dr.rceZdZdZeZedZedZ e Z edZ edZ dZ dZdZd Zd Zd Zd Zd ZdZdZdZeZeZeZy)r z Support for flags c|s||SdSt|} t|}d|dzzS#t$rtd|zdwxYw)z Generate the next value when not given. name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None NrMzinvalid flag value %rrA)max _high_bitrre)rIrPrr~ last_valuehigh_bits r+rzFlag._generate_next_value__sh!-5 41 4%  L ,HXaZ   L3j@At K Ls (Ac#Kt||jzD]}|jj|!yw)za Extract all members from the value in definition (i.e. increasing value) order. N)rqrrr)rr(vals r+rzFlag._iter_member_by_value_rs7 "%#//"9:C((,,S1 1;s<>c#ZKt|j|dEd{y7w)zI Extract all members from the value in definition order. c|jSr&)r)rIs r+rz+Flag._iter_member_by_def_..sannr.rN)r;rrXs r+rzFlag._iter_member_by_def_|s+ **51,  s !+)+c t|tst|d|j|j}|j }|j }d}||cxkr|kr nn|||z zr|jturRt|j|j}t|d|dt||dt|||jtur||z}ni|jtur|S|jtur)|dkr>t|dzd|jz|z}nt|d |j|dkr |}|dz|z}||z}||z}||z} |r<|jtur*t|jd |d |d t|d |j t"urt"j%|} n|j j%||} t'| ds|| _| s|r=g} d} |j+| D]"} | j-| | | j(z} $|rv| |z}|j.j1D]T\}}|| vs |j(s|j(|z|j(k(s5| j-|| |j(z} V|| z }dj3| D cgc]} | j4c} | _| sd| _nU|r"|jturt|d||r/| xj4d|j7|zz c_nd| _|j8j;|| } || |j8|<| Scc} w)z Create a composite member containing all canonical members present in `value`. If non-member values are present, result depends on `_boundary_` setting. rNz invalid value z given z allowed rrMrAz unknown flag boundary (z) --> unknown values z []r|z: no members with value z|%s)rRrrnr2rrrr'rrrzr|rrrr0rrr3r<rrrrrrrrrr)rr( flag_mask singles_maskall_bits neg_valuer~unknownaliasesr pseudo_memberr combined_valuerIr$pms r+rzFlag._missing_s^%%.3S5E5EF OO )) >> I2(2Hy01~~'u//193G3G3IJ E8(V7* )5( 4'19 A0@0@0B,CD#$ !9>**,,4 ;; !)6$,,+?@ @ %-dkk6$,,;OP Pr.c|jj}|j|d|jdS|d|jS)Nr)rQ)rr0rrr*rVs r+r*z Flag.__str__s9>>** ;; '6 6& 4 4r.c,t|jSr&)boolrrs r+rNz Flag.__bool__sDLL!!r.ct||jr |jS|jturt||jr|St Sr&)rRrrrrNotImplemented)r*flags r+ _get_valuezFlag._get_valuesB dDNN +<<    v -*T4CUCU2VKr.c|j|}|turtS||fD]"}|j|td|d|j}|j ||zS)N'z,' cannot be combined with other flags with |rrrerrr*r other_valuerr(s r+r,z Flag.__or__oooe, . (! !%KDt$,!D6)U VWW  ~~ek122r.c|j|}|turtS||fD]"}|j|td|d|j}|j ||zS)Nrz,' cannot be combined with other flags with &rrs r+r-z Flag.__and__rr.c|j|}|turtS||fD]"}|j|td|d|j}|j ||z S)Nrz,' cannot be combined with other flags with ^rrs r+r.z Flag.__xor__%rr.cX|j|td|d|js|jtt fvr-|j |j|_|jS|j |j|jz|_|jS)Nrz' cannot be inverted) rrer(r'rrrrrrs r+r2zFlag.__invert__0s ??4 (av%9:; ; ?? "5$-/"&..$,,"?#'..1D1D }1T"Ur.N)r0r1r2r3r#rrrrrrrrrYr^r_rr*rNrr,r-r.r2r0r/r1r4r.r+r r XsN!!$22+MZZx=4 (Q5" 3 3 3 HGHr.r rxceZdZdZy)r z) Support for integer-based Flags Nrr4r.r+r r @rr.r c(|jdz S)zJ returns index of highest bit, or -1 if value is zero or negative rM)rzr's r+rrFs     !!r.c ,g}|jjD]2\}}||jk7s|j||jf4|r:dj |Dcgc] \}}|d|c}}}t d|d||Scc}}w)zI Class decorator for enumerations ensuring unique member values. ,  -> zduplicate values found in r)r`rrIrrrn) enumeration duplicatesrIralias alias_detailss r+rrLsJ#//557 f 6;;    tV[[1 28 AKL ud+LN m-. . Ms$B cpjdjfdjDS)Nrc3^K|]$}|jr|dt|&yw)=N)r#rT)rkdcfr*s r+rz"_dataclass_repr..]s01v{{'$* +s*-)rrr )r*rs`@r+rr[s2  # #C 99XXZ r.ct|jjjdd}|d|jS)z{ use module.enum_name instead of class.enum_name the module is the last module in case of a multi-module name rQrL)rr1rr)r*rOs r+rrcs2 ^^ & & , ,S 1" 5Fdkk **r.c|jjjdd}|jj}|j|d|d|j dSt |j r|d|jS|jtjur=dj|jjdDcgc] }|d| c}Sg}|jjdD]=}|djr|j|(|j|d|?dj|Scc}w)z{ use module.flag_name instead of class.flag_name the module is the last module in case of a multi-module name rQrLrrrr)rr1rr0rrrbr'rrrrIisdigitr)r*rOrVrIr$s r+rrls  ^^ & & , ,S 1" 5F~~&&H {{$h ==dll# $++.. l///xxdiiooc>RS>RdFD1>RSTT""3'At||~ A vq12 ( xx~Ts E c|j(|jj}|d|jdS|jS)z2 use enum_name instead of class.enum_name rr)rrr0rrs r+rrs6 {{>>**#T\\22{{r.ct|tr t|_n t|_t|t r|r t |_tj|jjj|j|S)z decorator that makes the repr() of an enum member reference its module instead of its class; also exports all members to the enum's module's global namespace )rr rrrrrr*ryrr1rrr`)r update_strs r+rrsY #t' ' c8 $   KK((//@ Jr.)rrAcfd}|S)a Class decorator that converts a normal class into an :class:`Enum`. No safety checks are done, and some advanced behavior (such as :func:`__init_subclass__`) is not available. Enum creation can be faster using :func:`simple_enum`. >>> from enum import Enum, _simple_enum >>> @_simple_enum(Enum) ... class Color: ... RED = auto() ... GREEN = auto() ... BLUE = auto() >>> Color c |j} j|jjd}| |j}nj j }i}i}|||d<||d<|d<jx|d<}gx|d<}ix|d<}ix|d<} g|d <j x|d <} j|d <ttrxs j|d <d|d <d|d<d|d<d|d<tj|d<tj|d<tj|d<tj|d<tj |d<tj"|d<tj$|d<|jj'D]B\} } | dvr t)| s"t+|| st-| s t/| r| || <>| || <D|jjdd|d<t1|f|d} dD]O} | |vst3| }t3| | }t3t4| }t3| | }|||fvsCt7| | |Qg}t| trdx}}|j'D]U\} }t9|t:r*t:j<t>ur|| dtA||}|| vr;| |}tC}||_"|jG| | t7| | |||| <r"t9|tHs|f}|| g|}|d}n|| }|||_%| |_&| |_'|jQ|tC}||_"|jG| | t7| | |||| <tA||_)|| |<tU|r|jW| ||z}n||z}|jW|X||z| _,|| _-d ||zj]zdz | _/| Dcgc]}|jJ}}|ta|k7rs| jb| _2n`|j'D]L\} }t9|t:r7|j<t>ur|| dtA|||_|j<}|| vr;| |}tC}||_"|jG| | t7| | |||| <r"t9|tHs|f}|| g|}|d}n|| }|||_%| |_&| |_'|jQ|tA||_)tC}||_"|jG| | t7| | |||| <|| |<|jW| |jW|Od|vr| j | _3thj | _| Scc}w)!Nr3r:rrrrrrrrr&r'rrrr(r,r.r-r/r1r0r2)r __weakref__r3zAn enumeration.Trr+rrMrA)5r0rrrrrr3rr&rr r'r,r.r-r/r1r0r2rrJr_rNr>rSrTrrkrRrr(rrGrrrrrrrr,rrbrrrrzrr;rrr:r )rrVr3 new_memberattrsrgnvr>rvvalue2member_maprrIr=rrErFrGrHgnv_last_values single_bits multi_bitsr(rrrIrJrrrAs r+ convert_classz#_simple_enum..convert_classs <<  ''H,,""9-   ))J,,44J  %/D! ")^%\.3.I.II $%022 ,..^z8:: !"%5&( "#.3.A.AA_ $11^ eT "!)!=U-=-=D "&D !%D %)D! "!%D ![[DN"llDO"llDO"llDO#}}D #}}D !%D ++-ID#22$;x#>*TBRVdehVi T !d . <<  I & ./DO (UIthPTU JD4%eT2 &z48 ' 5 #*;#= $4m#DDJk:K j$ ''( (K*${{} eeT*tzzZ/Ga\):OLE,,-e4F'zH&,HO))*d;Jh7'-Jt$ )%7%*IE!+J!?!? %a!+J!7).$(FM*4F'OOE*'zH&,HO))*d;Jh7'-Jt$*-l*;F'.4$U+%e,$++D1#u, "e+ #**51M -N&1:%=J "(3J %$%;z+A*M*M*O$PST$TJ !.89j199jK9f[11+5+J+J ( %{{} eeT*{{j0&)$3|3Do&V !KKE,,-e4F'zH&,HO))*d;Jh7'-Jt$ )%7%*IE!+J!?!? %a!+J!7).$(FM*4F'OOE**-l*;F''zH&,HO))*d;Jh7'-Jt$.4$U+ ''-#**51G -H  (2(:(:J %!\\ Y:sWr4)rrrAr#s``` r+rrs Wp r.ceZdZdZdZdZdZy)rz8 various conditions to check an enumeration for zno skipped integer valuesz0multi-flag aliases may not contain unnamed flagszone name per valueN)r0r1r2r3rr r!r4r.r+rrFs-JDK !Fr.rceZdZdZdZdZy)rzG Check an enumeration for various constraints. (see EnumCheck) c||_yr&)checks)r*r's r+r,zverify.__init__Us  r.c <|j}|j}tt|trd}nt|trd}n t d|D]}|t urg}|jjD]2\}}||jk7s|j||jf4|s`dj|D cgc] \} }| d|c}} } td|d| |turtd|D} t| d krt!| t#| } } g}|dk(rCt%t'| d zt'| D]}d |z| vs |jd |z n>|dk(r+t%| d z| D]}|| vs|j|nt)d |z|setd |d |ddjd|Ddd|t*us|j,}|Dcgc]}|j.}}g}d}|j0jD]s\}} ||vr | j.dkrt3t5| j.} | Dcgc] }||vs| }}|sP|j||t7t8|z}u|sYt|d k(r d|dz} nddj|ddd|dd} t;|rd|z}nd|z}td|d| d |d|Scc}} wcc}wcc}w)Nrrz4the 'verify' decorator only works with Enum and Flagrr zaliases found in rc34K|]}|jywr&r')rrBs r+rz"verify.__call__..ms:kQWWksrArMzverify: unknown type %rzinvalid ryz: missing values c32K|]}t|ywr&)r)rrIs r+rz"verify.__call__..s;TGqCFGr%rzalias %s is missingzaliases rLrz are missingz value 0x%xzcombined values of 0x%xz invalid Flag z/ [use enum.show_flag_values(value) for details])r'r0r rr rer!r`rrIrrrnrrrGminrrangerrr rr(rrsrqr_or_rb)r*r r'rV enum_typecheckr rIrr r rUlowhighmissingrr>rI member_values missing_names missing_valuermissedr(s r+rVzverify.__call__Ws6''   ; =I  T *IRS SE $/$;$;$A$A$CLD&v{{*"))4*=>%D$(IIMWXZMUD5$7ZX%ZM$(-&9::*$:k::v;?KVT&"9S>!#3Yt_Ea4v-#NN1a40F&("3q5$/F?#NN1-0$$= $IJJ$%x;TG;T1U'W"s&$%%+%*99 2= >+Q+ > " ! #.#;#;#A#A#CKD%|+ {{Q !."=>F)/JA1M3IaFJ%,,T2%f)== $D!=)Q. 5 a8H H/!% -*< =}R?P!"&m4 ,} < 9M I$'7AHwY:!?KsL >L. L8LN)r0r1r2r3r,rVr4r.r+rrQsMr.rc \g}|j|jk7rq|j}t|j}|j}t|j}tt|jjt|jjz}t||zD]}|dvr ||vr||vr|j d|'||vr|j d|@||} ||} t | st| tjrp|dk(rj| jddjdd} | jddjdd} | | k7s|j |dd | d d | | | k7s|j |dd | d d | |j|D]/} g}| |vr|j d | zn| |vr|j d | zn|| j}t|j}|| j}t|j}t||zD]n}|dvr||vr|j d|d| $||vr|j d|d| @||} ||} | | k7sP|j |dd| d d| p|s |j | ddj|2dD]x}||vr||vr ||vri||vret||d}t||d}t|dr|j}|j}||k7sX|j |dd |ddd|yz|rt!ddj|zy)a] A function that can be used to test an enum created with :func:`_simple_enum` against the version created by subclassing :class:`Enum`:: >>> from enum import Enum, _simple_enum, _test_simple_enum >>> @_simple_enum(Enum) ... class Color: ... RED = auto() ... GREEN = auto() ... BLUE = auto() >>> class CheckedColor(Enum): ... RED = auto() ... GREEN = auto() ... BLUE = auto() >>> _test_simple_enum(CheckedColor, Color) If differences are found, a :exc:`TypeError` is raised. )r1rrr3z missing key: z extra key: r3ryrP z : z checked -> z z simple -> z#missing member from simple enum: %rzextra member in simple enum: %r)r1rr(z missing key z not in the simple enum member z extra key z in simple enum member zchecked member -> zsimple member -> z member mismatch: z )r*rrir)__getnewargs_ex____getnewargs__ri __reduce__Nrz: 30z simple -> zenum mismatch: %sz )rrsr rrrcallablerRr{rr}rrrTr<rre) checked_enum simple_enumfailed checked_dict checked_keys simple_dict simple_keysr>r checked_value simple_valuecompressed_checked_valuecompressed_simple_valuerI failed_memberchecked_member_dictchecked_member_keyssimple_member_dictsimple_member_keysrDchecked_method simple_methods r+_test_simple_enumrQs&F 4 44#,, L--/0 !** ;++-. \..3356{//44678 |k12CUU $K' 39:L( 39: ,S 1 *3/ M*j.W)#/#73@   DM;& CdJK\) ?$FG&24&8&A&A#&*+>+C+C+E&F#%0%6%?%?"%)*<*A*A*C%D"25GGHCJJ $66%,,begk-lm$77%,,X[]a-bc(;C(@ '9#'> (L8)00$'>K$N>J$M2&'I" joom<;!@F$<)?{*v\/I!(vt!D ' VT B >:6%3%<%#/0/',,v2FFGGr.cZtj|j}|r |j}n|}|jDcgc]\}}||r||f}}} |j d||||xst } | Scc}}w#t $r|j dY:wxYw)zS Create a new Enum subclass that replaces a collection of global constants c|d|dfSrr4rs r+rz_old_convert_..6sAaD!A$.9s1Q4r.)rOr)ryrrrrrer) rrIrOrrrrr(r rs r+ _old_convert_rUs[[(11N  &||~- ed|5M- ) / 0 gfx7G4 HC J )  ()sBB B*)B*r&)F)Drybuiltinsr{typesrroperatorrr. functoolsr__all__r r r _stdlib_enumsrrrrr>rJrNrZr_rbrlrqrtr|rrrrrrrjrrSrrrr rr r"_reduce_ex_by_global_namer#rrrrr rrrrrrrrrrr r!rrQrUr4r.r+r]s 9  2655t5e5mhV  A  0 '$0 \ \ ''6+$6+r99DAAHz+tz+v UXUpt c8 c8D22 7  ,e4&ePc8TD " +. hhTg"""#, KSSjwHr<') r.