
    (g>                       d dl Z d dlZd dlmZmZ d dlmZ d dl	m
Z
 g dZdxZxZxZxZZ G d de      Z G d d	e      Zd
 Zd Zd Zd Zd Zd Zd Zd Zd ZdDdZd Z G d d      Z e       Z G d d      Z  e        Z  G d d      Z! G d de      Z" G d d      Z# G d d e$      Z% G d! d"e&      Z'e'Z( G d# d$e'%      Z G d& d'e      Z G d( d)e)e      Z* G d* d+e+e      Z,d, Z-e-Z.d- Z/ G d. d/e,      Z0e0\  Z1Z2ZZ3 G d0 d1ee12      Z G d3 d4e)eee32      Z4d5 Z5d6 Z6d7 Z7d8 Z8d9 Z9d: Z:dEd;Z;efddd<d=Z< e<e,       G d> d?             Z=e=\  Z>Z?Z@ G d@ dA      ZAdB ZBdDdd2dCZCe*e,e4fZy)F    N)MappingProxyTypeDynamicClassAttribute)or_)reduce)EnumTypeEnumMetaEnumIntEnumStrEnumFlagIntFlagReprEnumautouniquepropertyverifymember	nonmemberFlagBoundarySTRICTCONFORMEJECTKEEPglobal_flag_reprglobal_enum_repr
global_strglobal_enum	EnumCheck
CONTINUOUSNAMED_FLAGSUNIQUEpickle_by_global_namepickle_by_enum_namec                       e Zd ZdZd Zy)r   zK
    Protects item from becoming an Enum member during class creation.
    c                     || _         y Nvalueselfr(   s     /usr/lib/python3.12/enum.py__init__znonmember.__init__   	    
    N__name__
__module____qualname____doc__r,    r.   r+   r   r          r.   r   c                       e Zd ZdZd Zy)r   zE
    Forces item to become an Enum member during class creation.
    c                     || _         y r&   r'   r)   s     r+   r,   zmember.__init__#   r-   r.   Nr/   r4   r.   r+   r   r      r5   r.   r   c                 R    t        | d      xs t        | d      xs t        | d      S )z?
    Returns True if obj is a descriptor, False otherwise.
    __get____set__
__delete__)hasattr)objs    r+   _is_descriptorr>   &   s1    
 C# 'C#'C&r.   c                 v    t        |       dkD  xr* | dd | dd cxk(  xr dk(  nc xr | d   dk7  xr | d   dk7  S )z=
    Returns True if a __dunder__ name, False otherwise.
       N   ___lennames    r+   
_is_dunderrJ   0   sT    
 IM !HRS	)T)GsN HO	r.   c                 v    t        |       dkD  xr* | d   | d   cxk(  xr dk(  nc xr | dd dk7  xr | dd dk7  S )z;
    Returns True if a _sunder_ name, False otherwise.
    rA   r   rD      rB   rF   rH   s    r+   
_is_sunderrN   ;   sV    
 IM GtBx&3&1I BK3	r.   c                     t        |t              syt        |dd      }| dz   t        |dd      z   }d|z   }||k(  xs |j                  |      S )NFr2    .r0   )
isinstancetypegetattrendswith)cls_namer=   qualname	s_pattern	e_patterns        r+   _is_internal_classrZ   F   sX    c4 sNB/H3j"!==IiIy @H$5$5i$@@r.   c                     d| d}t        |      }t        |      |kD  r.|j                  |      r|||dz    dgk7  r|d   dk7  s|d   dk7  ryy)NrD   rC   rM   rL   rB   TF)rG   
startswith)rV   rI   patternpat_lens       r+   _is_privater_   O   s[    !$G'lGI(WWQY'C50bSDHOr.   c                 (    | dk(  ry| | dz
  z  } | dk(  S )z<
    True if only one bit set in num (should be an int)
    r   FrM   r4   )nums    r+   _is_single_bitrb   ]   s$     ax37NC!8Or.   c                 t    d }t        | t              r|| d<   d| d<   yt        | d|       t        | dd       y)z]
    Make the given obj un-picklable.

    obj should be either a dictionary, or an Enum
    c                     t        d| z        )Nz%r cannot be pickled)	TypeErrorr*   protos     r+   _break_on_call_reducez6_make_class_unpicklable.<locals>._break_on_call_reducel   s    .566r.   __reduce_ex__z	<unknown>r1   N)rR   dictsetattr)r=   rh   s     r+   _make_class_unpicklablerl   f   s>    7#t4O'L_&;<\;/r.   c              #      K   | }t        | t              r| j                  } | dk  rt        d|z        | r| |  dz   z  }| | |z  } | ry y w)Nr   z%r is not a positive integerrM   )rR   r	   r(   
ValueError)ra   originalbs      r+   _iter_bits_lsbrq   u   s\     H#tii
Qw7(BCC
C4!8q s   AAAc                 *    t        t        |             S r&   )listrq   r'   s    r+   show_flag_valuesrt      s    u%&&r.   c                 $   d| j                         z  }| dk\  r*t        j                  | |z         j                  ddd      }nt        j                  |  |dz
  |z   z        }|dd }|dd }|t	        |      |k  r|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'
    rA   r   10rM   N   rL    )
bit_lengthbltnsbinreplacerG   )ra   max_bitsceilingssigndigitss         r+   r|   r|      s     C##%%G
axIIcGm$,,S#q9IIsdgkW445Ra5DqrUFv;!2h)F2XIJ?FF##r.   c                     | j                  d      }d}t        |d         D ]  \  }}|dk7  s n t        |      D ]  \  }}|d ||<    dj                  |      S )zM
    Like textwrap.dedent.  Rewritten because we cannot import textwrap.
    
r   ry   N)split	enumeratejoin)textlinesblanksichjls          r+   _dedentr      su     JJtEF58$ 29 %  1QR5a99Ur.   c                       e Zd Zd Zy)
_not_givenc                      y)Nz<not given>r4   r*   s    r+   __repr__z_not_given.__repr__   s    r.   Nr0   r1   r2   r   r4   r.   r+   r   r      s    r.   r   c                       e Zd Zd Zy)
_auto_nullc                      y)Nr   r4   r   s    r+   r   z_auto_null.__repr__   s    r.   Nr   r4   r.   r+   r   r      s    r.   r   c                        e Zd ZdZefdZd Zy)r   zP
    Instances are replaced with an appropriate value in Enum class suites.
    c                     || _         y r&   r'   r)   s     r+   r,   zauto.__init__   r-   r.   c                      d| j                   z  S )Nzauto(%r)r'   r   s    r+   r   zauto.__repr__   s    DJJ&&r.   N)r0   r1   r2   r3   r   r,   r   r4   r.   r+   r   r      s     ( 'r.   r   c                   6    e Zd ZdZdZdZdZddZd Zd Z	d Z
y)r   aI  
    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                   | j                   S t        |d| j                        | j                  | j                  |      S | j                  dk(  r t        | j                  | j                        S | j                  dk(  r t        |j                  | j                        S 	 |j                  | j                     S # t        $ r t        |d| j                        d w xY w)Nz has no attribute attrdesc)
r   AttributeErrorrI   fget
_attr_typerT   	_cls_type_value__member_map_KeyError)r*   instance
ownerclasss      r+   r9   zproperty.__get__   s    {{&{{"$4>		J  99 99X&&__&4>>49955__&8++TYY77	 **49955 	  0:DIIF 	 s   1C
 
%C/c                     | j                   | j                  ||      S t        d| j                  d| j                        )N<enum z> cannot set attribute )fsetr   clsnamerI   )r*   r   r(   s      r+   r:   zproperty.__set__   s:    99 99Xu--7;||TYYO 	r.   c                     | j                   | j                  |      S t        d| j                  d| j                        )Nr   z> cannot delete attribute )fdelr   r   rI   )r*   r   s     r+   r;   zproperty.__delete__   s8    99 99X&&:>,,		R 	r.   c                 4    || _         |j                  | _        y r&   )rI   r0   r   )r*   r   rI   s      r+   __set_name__zproperty.__set_name__   s    	!**r.   r&   )r0   r1   r2   r3   r   r   r   r9   r:   r;   r   r4   r.   r+   r   r      s,     FJI 2+r.   r   c                       e Zd ZdZd Zd Zy)_proto_memberzW
    intermediate step for enum members between class execution and final creation
    c                     || _         y r&   r'   r)   s     r+   r,   z_proto_member.__init__   r-   r.   c                    t        ||       | j                  }t        |t              s|f}n|}|j                  t        u r|f}|j
                  s|j                  |      }n |j                  |g| }t        |d      s/|j                  t        u r||_	        n	  |j                  | |_	        |j                  }||_        ||_         |j                  |  t!        |j"                        |_        t&        zt)        |t&              rjt        |t*              r5|xj,                  |z  c_        t/        |      r|xj0                  |z  c_        d|j,                  j3                         z  dz
  |_        	 	 |j6                  |   }d}
d}d}|j@                  dd D ]\  }|jB                  jE                  |      }|!t        |tF        tH        f      r|}
|}d} n tK        |      r|}
|xs d}|xs |}Yd}|}^ |
rtG               }||_&        |jO                  ||       |d	v rltQ        |
d
d      |_)        tQ        |
dd      |_*        tQ        |
dd      |_+        tQ        |
dd      |_,        tQ        |
dd      |_-        tQ        |
dd      |_.        ||_/        ||_0        tc        |||       ntc        |||       ||j8                  |<   	 |j6                  je                  ||       y# t        $ r}t        d      }||_        |d}~ww xY w# t        $ r? |j8                  j;                         D ]  \  }}	|	j                  |k(  s|	} n t<        Y w xY w# t<        $ r t&        t)        |t&              s|j"                  j?                  |       nLt&        Ft)        |t&              r6t        |t*              r&t/        |      r|j"                  j?                  |       Y Yw xY w# t        $ r |jf                  j?                  |       Y yw xY w)zR
        convert each quasi-member into an instance of the new enum class
        r   z/_value_ not set in __new__, unable to create itNrA   rM   enumr   r   )r   r   r   r9   r   r:   r   r;   )4delattrr(   rR   tuple_member_type_
_use_args__new_member_r<   objectr   	Exceptionre   	__cause___name___objclass__r,   rG   _member_names__sort_order_r   
issubclassint_flag_mask_rb   _singles_mask_rz   
_all_bits__value2member_map_r   itemsr   append__mro____dict__getr   r   r>   r   r   rT   r   _getr   _setr   _delr   r   rk   
setdefault_unhashable_values_)r*   
enum_classmember_namer(   argsenum_memberexcnew_excrI   canonical_memberfound_descriptordescriptor_type
class_typebaser   redirects                   r+   r   z_proto_member.__set_name__   s   
 	
K(

%'9DD##u,8D$$$11*=K1*11*DtDK{I.''61&+#"*B**B*BD*IK' ##(#- d##&z'@'@#A 
:t <%%&&%/&!%(--6-$%:+A+A*M*M*O$PST$TJ!	>	#(;;EB4  
&&qr* 	&D==$$[1DdX/D$EF'+$!%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 ! "'MG ),G%!M"2  #.8.E.E.K.K.M #*D*'//58&6#
 #N 	#  	> L%j$7 ))00=$":t4"5#.&u- ))00=!	>z  	9**11%8	9s[   K# 5L O! #	L,L  L8MMM MM BOO!$PPN)r0   r1   r2   r3   r,   r   r4   r.   r+   r   r      s    w9r.   r   c                   2     e Zd ZdZ fdZ fdZd Z xZS )	_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.
    c                 Z    t         |           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                  |      rddl}|j                  dt        d       t        | j                  |      rnt        |      r|dvrt        d|d      |d	k(  rD| j                  rt        d
      t        |t              r|j                  n|}t        | d|       nH|dk(  rBt        |t              r!|j                  dd      j!                         }nt#        |      }|| _        t'        |      t'        | j(                        z  }|rt        d|      t+        |      r
|dk(  rd}n|| j(                  v rt        |d| |         || j$                  v rnt        |t,              r|j.                  }nit1        |      rn\|| v rt        |d| |         t        |t2              r|j.                  }d}d}t        |t4              rd}|f}t        |t6              rt9        d |D              rg }t;        |      }	|D ]  }
t        |
t4              r|d}|
j.                  t<        k(  r@| j?                  |dtA        | j(                        | jB                  dd       |
_        d| _        |
j.                  }
| jB                  jE                  |
       |jE                  |
        |r|d   }n		  |	|      }d| j(                  |<   |r| jB                  jE                  |       tF        |   ||       y# t        $ r  |	| }Y Mw xY w)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.
        r   NzzIn 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 user   z4_generate_next_value_ must be defined before members_generate_next_valuer   ,ry   z+_ignore_ cannot specify already set names: 	__order__r   z already defined as TFc              3   <   K   | ]  }t        |t                y wr&   )rR   r   ).0vs     r+   	<genexpr>z(_EnumDict.__setitem__.<locals>.<genexpr>  s     /S
1d0C/Ss   rM   )%rZ   	_cls_namewarningswarnDeprecationWarningr_   rN   rn   r   re   rR   staticmethod__func__rk   strr}   r   rs   r   setr   rJ   r   r(   r>   r   r   r   anyrS   r   r   rG   r   r   r   __setitem__)r*   keyr(   r   _gnvalreadynon_auto_storesingleauto_valuedtr   r   s              r+   r  z_EnumDict.__setitem__  s    dnne4MMO& 	   t~~s+_  
 !"  --$$#$Z[[)3E<)Hu~~e4d;
"eS)!MM#c288:E KE$e*s4+=+='>>$&*  _k!D&&&#tCyIJJDLL y)KKEE" d{c49 MNNE6*!NF%&	%'C/SU/S,S !K 
*A!!T*).77j0&*&?&?$'C0B0B,CTEVEVWXEY'&AG 15D-GG))003&&q)
* 'NE0 !+ '+Ds#!!((/C' % 0 !;0s   L LLc                     	 |j                         D ]
  }||   | |<    	 |j                         D ]
  \  }}|| |<    y # t        $ r |D ]
  \  }}|| |<    Y 8w xY wr&   )keysr   r   )r*   membersmore_membersrI   r(   s        r+   updatez_EnumDict.update  s}    	# +$T]T
+
 (--/ 	KD%DJ	  	#& #e"T
#	#s   > AA)r0   r1   r2   r3   r,   r  r  __classcell__r   s   @r+   r   r   x  s    "i(Vr.   r   c                   .    e Zd ZdZed        Zddd fd
Zd Zefdddddd	d
Z	d Z
 fdZd Zd Zd Zd Zej"                  d        Zd Zd Z fdZdddddd	dZdddddZed        Zed        Zed        Zed        Zed        Z xZS )r   z
    Metaclass for Enum
    c                     | j                  ||       t               }||_        | j                  ||      \  }}|t	        |dd       |d<   |S )Nr   )_check_for_existing_members_r   r   _get_mixins_rT   )metaclsclsbaseskwds	enum_dictmember_type
first_enums          r+   __prepare__zEnumType.__prepare__  s`     	,,S%8K	!	")"6"6sE"BZ!18 72I-. r.   NFboundary_simplec                $
   |rt         |   | |||fi |S |j                  dg       j                  d       |d   }|D ]  }|j	                  |d         |j
                  }	t        |	      ddhz  }
|
r$t        ddj                  d |
D              z        |j	                  dd       }|j                  d      }|t        |      t        urt        |      }t        |j                               }|||d<   | j                  ||      \  }}| j                  |||      \  }}}||d	<   ||d
<   |	D ]  }||   }t!        |      ||<    g |d<   i |d<   i |d<   g |d<   ||d<   | j#                  ||      |d<   |xs t%        |dd       |d<   d|d<   d|d<   d|d<   d |d<   	 d }t         |   | |||fi |}||j1                        |j3                  j4                         t6        t6        |v r{|t8        u rt;        d      d|vr |j<                  |_        |j<                  |d<   d|vr@|j>                  }|t8        j>                  u r|j@                  }||_        |j>                  |d<   dD ]O  }||vst%        ||      }t%        ||      }t%        t8        |      }t%        ||      }|||fv sCtC        |||       Q tD        >tG        |tD              r.dD ])  }||vst%        tD        |      }tC        |||       |||<   + tH        |r||_%        tH        j                  |_        |0tM        |t(              r |jO                  dd      jQ                         }tD        |dk7  stD        MtG        |tD              s=tS        |d       tS        |d       tS        |d       tS        |d       tS        |d       ntD        tG        |tD              ro|D cg c]  }|jT                   }}|tW        |      k7  r|jX                  |_-        |r5|D cg c]*  }||j\                  vst_        ||   jT                        r|, }}|rc|D cg c].  }||j\                  vs||j\                  v r||j`                  v r|0 }}||j`                  k7  rt;        d|j`                  d|      |S # t&        $ rS} t        |      t)        |            }|j*                  |_        |j,                  |_        |j.                  }Y d }~Fd }~ww xY wc c}w c c}w c c}w ) Nr   mrorP   zinvalid enum member name(s) %sr   c              3   2   K   | ]  }t        |        y wr&   )repr)r   ns     r+   r   z#EnumType.__new__.<locals>.<genexpr>&  s     <T!W<   r   r   r   r   r   r   r   r   r   _value_repr_
_boundary_r   r   r   r   
_inverted_zOReprEnum subclasses must be mixed with a data type (i.e. int, str, float, etc.)
__format____str__r   r*  r)  ri   )__or____and____xor____ror____rand____rxor__
__invert__ry   r   z'member order does not match _order_:
  z
  )1r   __new__r   r   popr   r   rn   r   r   rS   r   rj   r   r  
_find_new_r   _find_data_repr_rT   r   r   r   __context____traceback__with_tracebackr  r   r   r   re   r)  r*  r   rk   r   r   r	   __new_member__rR   r}   r   r   r   sortedr   r   r   rb   r   )!r  r  r  	classdictr  r  r  ignorer  member_namesinvalid_namesr   r  r  r  r3  save_newuse_argsrI   r(   r   r   etbmethodenum_methodfound_methodobject_methoddata_type_methodmmember_listor   s!                                   r+   r3  zEnumType.__new__  s    7?7C	JTJJ 	Z,33J?:& 	%CMM#t$	% !.. L)UBK7=HH<m<<  
 --	40}}45T
, >%D*+	15I-. #*"6"6sE"BZ&-&8&8;
'#8 %,	.!"*	, ! 	3DdOE+E2IdO	3
 ')	"#$&	.!*,	&'+-	'(%0	/"$+$<$<S%$H	.!  ;:|T: 	, $%	- &'	"#"#	,"&	,
	!C#uiP4PJ ?$$R(( 	,,- H$5f$2  9,(3(>(>
%*4*?*?	,'	)$,,V^^+ )11F%+
"'1'9'9	)$J 	;D9$%j$7&z48 ' 5#*;#= $4m#DDJk:	; 
:t < 2
 y(")$"5KJk:&1IdO2  ,3
)!%J '3'!//#s399; #Jz4,HJ-J.J 01J-J-*Z">.891999K9f[11+5+J+J
( ")J$;$;;~jYZmNcNc?d    %!8!88j555!z?X?X:X G  *333%44g? 
 s  	! $q'#a&/CKKCMmmCOB	!z :
s+    R$ T/T3T$	T -AS;;T c                      y)z6
        classes/types should always be True.
        Tr4   r  s    r+   __bool__zEnumType.__bool__  s     r.   rM   )modulerW   rS   startr  c          	          | j                   r!|t        ur||f|z   }| j                  | |      S |t        u r|t        |  d      | j	                  ||t        u rdn||||||      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_namenamesrO  rW   rS   rP  r  )r   r   r3  re   _create_)	r  r(   rS  rO  rW   rS   rP  r  valuess	            r+   __call__zEnumType.__call__  s    6 J&/;;sE**J4<ehi  || #z1du!!   	r.   c                 X    t        ||       ry|| j                  v xs || j                  v S )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)rR   r   r   r  r(   s     r+   __contains__zEnumType.__contains__  s2     eS!...R%3;R;R2RRr.   c                 v    || j                   v rt        | j                  d|d      t        |   |       y )Nz cannot delete member rQ   )r   r   r0   r   __delattr__)r  r   r   s     r+   r[  zEnumType.__delattr__  s5     3### #,,PT!UVVD!r.   c                 x   t        g d| j                  z         }| j                  t        j                  ur|j                  d       | j                  t        j                  ur|j                  d       | j                  t        u rt        |      S t        t        t        | j                              |z        S )N)
r   rY  r3   __getitem____iter____len____members__r1   r0   r2   r3  __init_subclass__)
r   r   r   r   r3  addra  r   r;  dir)r  interestings     r+   __dir__zEnumType.__dir__  s     
 $$%  6>>1OOI&  (@(@@OO/0&+&& #c#"3"345CDDr.   c                      | j                   |   S )z4
        Return the member matching `name`.
        r   )r  rI   s     r+   r]  zEnumType.__getitem__*  s     %%r.   c                 .      fd j                   D        S )z5
        Return members in definition order.
        c              3   <   K   | ]  }j                   |     y wr&   rg  r   rI   r  s     r+   r   z$EnumType.__iter__.<locals>.<genexpr>4  s     F4  &F   r   rM  s   `r+   r^  zEnumType.__iter__0  s     G33E3EFFr.   c                 ,    t        | j                        S )z;
        Return the number of members (no aliases)
        )rG   r   rM  s    r+   r_  zEnumType.__len__6  s     3%%&&r.   c                 ,    t        | j                        S )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.
        )r   r   rM  s    r+   r`  zEnumType.__members__<  s       0 011r.   c                 j    t         t        | t               rd| j                  z  S d| j                  z  S )Nz	<flag %r>z	<enum %r>)r   r   r0   rM  s    r+   r   zEnumType.__repr__F  s/    
3 5----r.   c                 @      fdt         j                        D        S )z=
        Return members in reverse definition order.
        c              3   <   K   | ]  }j                   |     y wr&   rg  rj  s     r+   r   z(EnumType.__reversed__.<locals>.<genexpr>P  s     P4  &Prk  )reversedr   rM  s   `r+   __reversed__zEnumType.__reversed__L  s     Q8C<N<N3OPPr.   c                     | j                   j                  di       }||v rt        d|      t        |   ||       y)a  
        Block attempts to reassign Enum members.

        A simple assignment to the class namespace only changes one of the
        several possible ways to get an Enum member from the Enum class,
        resulting in an inconsistent Enumeration.
        r   zcannot reassign member N)r   r   r   r   __setattr__)r  rI   r(   
member_mapr   s       r+   ru  zEnumType.__setattr__R  s@     \\%%nb9
: !GHHD%(r.   c          	      \   | j                   }|| fn|| f}	| j                  ||	      \  }
}|j                  ||	      }t        |t              r |j                  dd      j                         }t        |t        t        f      ri|rgt        |d   t              rT|g }}g }t        |      D ]@  \  }}|j                  ||||dd       }|j                  |       |j                  ||f       B |d}|D ]$  }t        |t              r|||   }}n|\  }}|||<   & |	 t        j                  d      }|t'        |       n||d<   |||d	<   |j)                  |||	||
      S # t        $ rA 	 t        j                  d      j                   d   }n# t        t"        t$        f$ r Y nw xY wY yw xY w)a  
        Convenience method to create a new Enum class.

        `names` can be:

        * A string containing member names, separated either with spaces or
          commas.  Values are incremented by 1 from `start`.
        * An iterable of member names.  Values are incremented by 1 from `start`.
        * An iterable of (member name, value) pairs.
        * A mapping of member name -> value pairs.
        Nr   ry   r   r4   rA   r0   r1   r2   r  )r   r  r  rR   r   r}   r   r   rs   r   r   r   sys_getframemodulenamer   	_getframe	f_globalsrn   r   rl   r3  )r  rR  rS  rO  rW   rS   rP  r  r  r  rD   r  r<  original_nameslast_valuescountrI   r(   itemr   member_values                        r+   rT  zEnumType._create__  s    --<dC[((U;:''
E:	 eS!MM#s+113EeeT]+*U1Xs:S$)2ENK(8 ,t"88ue[YZ^\""5)dE]+, =E  	2D$$,0%+\,0)\%1Ik"	2 >003 >#I.&,Il#(0In%w
E9xXX "  ]]1-77
CF&
H= 	s6   E! !	F++"FF+F%"F+$F%%F+*F+)r  	as_globalc                r   t         j                  |   j                  }|r|j                  }n|}|j                         D cg c]  \  }} ||      r||f }	}}	 |	j	                  d        |	D 
ci c]  }
|
d   |
d    }}
||d<   t        t        f|      } t        | |xs t              |      } |rt        |        n@t         j                  | j                     j                  j                  | j                         | ||<   | S c c}}w # t
        $ r |	j	                  d        Y w xY wc c}
w )z[
        Create a new Enum subclass that replaces a collection of global constants
        c                     | d   | d   fS NrM   r   r4   r	  s    r+   <lambda>z$EnumType._convert_.<locals>.<lambda>  s    !ad| r.   r  c                     | d   S Nr   r4   r  s    r+   r  z$EnumType._convert_.<locals>.<lambda>  s
    qt r.   r   rM   r1   )etyper  )ry  modulesr   r   sortre   rS   r   _simple_enumr   r   r1   r  r`  )r  rI   rO  filtersourcer  r  module_globalsr(   r  r	  bodytmp_clss                r+   	_convert_zEnumType._convert_  s+    V,55__F#F $*<<>!D%$< u! !	-LL3L4 %,,q!ad
,,#\tfZ.@lx/?4@IKK'0077H"t
'!  	-LL^L,	- -s   DD 3D4D10D1c                     |D ]A  }|j                   D ]0  }t        |t              s|j                  s!t	        d|d|       C y )Nr   z> cannot extend )r   rR   r   r   re   mclsrR  r  chainr   s        r+   r  z%EnumType._check_for_existing_members_  sM     	E dH-$2E2E#)41 	r.   c                     |st         t        fS |d   }t        |t              st	        d      | j                  ||      xs t         }||fS )z
        Returns the type for creating enum members, and the first inherited
        enum class.

        bases: the tuple of bases that was given to __new__
        rL   zZnew enumerations should be created as `EnumName([mixin_type, ...] [data_type,] enum_type)`)r   r	   rR   r   re   _find_data_type_)r  rR  r  r  r  s        r+   r  zEnumType._get_mixins_  s]     4< 2Y
*h/ K L L++J>H&J&&r.   c                 F   |D ]  }|j                   D ]  }|t        u rt        |t              r|j                  c c S d|j
                  v s;d|j
                  v r1d|j
                  v r#|j
                  d   j                  r
t        c c S |j
                  d   c c S   y )Nr   __dataclass_fields____dataclass_params__)r   r   rR   r   r&  r   r#  _dataclass_reprr  s        r+   r6  zEnumType._find_data_repr_  s     	9E 96>h/,,,4==0 3dmmC 6$-- G $.D E J J..#}}Z88!9	9$ r.   c                    t               }t               }|D ]  }d }|j                  D ]  }|j                  |       |t        u rt	        |t
              r0|j                  t        us@|j                  |j                          nd|j                  v sd|j                  v r|j                  |xs |        |xs |}  t        |      dkD  rt        d|d|      |r|j                         S y )Nr3  r  rM   ztoo many data types for : )r   r   rb  r   rR   r   r   r   rG   re   r4  )r  rR  r  
data_types
base_chainr  	candidater   s           r+   r  zEnumType._find_data_type_  s     U
U
 	2EI 2t$6>h/))7"t'9'9:$--/3IT]]3ZNN9#45 ) 1TI2	2 z?Q
JWXX>>##r.   c                 `   |j                  dd      }|duxr |du}|cdD ]N  }||fD ]A  }t        ||d      }|ddj                  t        j                  t        j                  hvs?|} n |N n t        j                  }|"|t        j                  t        j                  fv rd}	nd}	|||	fS )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__
        r3  N)r:  r3  FT)r   rT   r3  r   r	   )
r  r<  r  r  r3  r@  rD  possibletargetrA  s
             r+   r5  zEnumType._find_new_  s     --	40 T)AgT.A? 8 )!,j 9 	H$Xvt<F  LL"NN LL	&  #)	 &) !..
 T\\6>>,J!JHH(**r.   r&   )r0   r1   r2   r3   classmethodr  r3  rN  r   rV  rY  r[  re  r]  r^  r_  r{   r   r`  r   rs  ru  rT  r  r  r  r6  r  r5  r  r  s   @r+   r   r     s       =A% ~@ $. .tdY]efqu .`	S"E$&G' ^^2 2.Q) 48$TYZei 6Yp$dV[ $L   ' '$  *  4 *+ *+r.   r   c                       e Zd ZdZed        Zd Zd Zed        Z	ed        Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zed        Zed        Zy)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
      <Color.RED: 1>

    - value lookup:

      >>> Color(1)
      <Color.RED: 1>

    - name lookup:

      >>> Color['RED']
      <Color.RED: 1>

    Enumerations can be iterated over, and know how many members they have:

    >>> len(Color)
    3

    >>> list(Color)
    [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

    Methods can be added to enumerations, and members can have their own
    attributes -- see the documentation for details.
    c                     | j                   ryy)Nz	(*values)z\(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)rl  rM  s    r+   __signature__zEnum.__signature__b  s    qr.   c                    t        |      | u r|S 	 | j                  |   S # t        $ r Y nBt        $ r7 | j                  j                         D ]  }|j                  |k(  s|c cY S  Y nw xY w| j                  st        d| z        	 d }| j                  |      }n# t        $ r}|}d }Y d }~nd }~ww xY w	 t        ||       r|d }d }S t        8t        | t              r(| j                  t        u rt        |t              r|d }d }S t        |d| j                         }||||t        d| j"                  d|d      }t        |t              s||_        |# d }d }w xY w)Nz%r has no members defined is not a valid z	error in z._missing_: returned z" instead of None or a valid member)rS   r   r   re   r   rU  r   r   r   rR   r   r   r'  r   r   rn   r2   r0   r7  )r  r(   r   r   resultrB  ve_excs          r+   r3  zEnum.__new__i  s}    ;#L		"))%00 	 	"**113 ">>U*!M"	" 7#=>>	C]]5)F 	CF		&#&( CF' $C)>%/Jvs4K CF $eSEUEU$VW>ck L[#"||V5C "#z2&,CO	 CFsQ     	A*4A* A*&A*)A*B 	B3%B..B37E 	9E AE E$c                      y r&   r4   )r*   r   r  s      r+   r,   zEnum.__init__  s    r.   c                    |s|S 	 |d   }|j                          ||d   k(  r|dz   S t        # t        $ rI ddl}|j                  dt        d       t        |      D ]  }	 |dz   c cY S # t        $ r Y w xY w |cY S w xY w)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
        rL   rM   r   NzIn 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 1rx   r   )r  re   r   r   r   rr  )rI   rP  r  r~  lastr   r   s          r+   r   zEnum._generate_next_value_  s     L	r?D{2&ax   	MMd& 	   k* q5L  
 L	s7   !. . 3B "A+&B +	A74B 6A77B ?B c                      y r&   r4   rX  s     r+   r   zEnum._missing_  s    r.   c                     | j                   j                  xs t        }d| j                   j                  d| j                  d || j
                        dS )N<rQ   r  >)r   r&  r#  r0   r   r   )r*   v_reprs     r+   r   zEnum.__repr__  s:    ,,4 $ 7 7fT\\FZ[[r.   c                 L    | j                   j                  d| j                  S )NrQ   )r   r0   r   r   s    r+   r*  zEnum.__str__  s    ..114;;AAr.   c                    t               }| j                  j                  t        urt        t        j	                  |             }t        | dg       D ]+  }|d   dk7  s|| j                  vs|j                  |       - | j                  j                         D ]  }|j                  j                         D ]|  \  }}|d   dk(  rt        |t              r>|j                  || j                  vr|j                  |       K|j                  |       ]|| j                  vsl|j                  |       ~  t        t        g d      |z        }|S )zJ
        Returns public methods and other interesting attributes.
        r   r   rD   )r   r3   __eq____hash__r1   )r   r   r   r   re  rT   r   rb  r!  r   r   rR   r   r   discardr;  )r*   rd  rI   r  r=   rS  s         r+   re  zEnum.__dir__  s3    e>>''v5fnnT23KD*b1 	&DAw#~$d.?.?"?%	& >>%%' 	*C \\//1 *	c7c>c8,xx+t4;L;L/L#- $++D1!2!22OOD)*	* PQ r.   c                 @    t         j                  t        |       |      S r&   )r   r)  )r*   format_specs     r+   r)  zEnum.__format__  s    ~~c$i55r.   c                 ,    t        | j                        S r&   )hashr   r   s    r+   r  zEnum.__hash__  s    DKK  r.   c                 4    | j                   | j                  ffS r&   )r   r   rf   s     r+   ri   zEnum.__reduce_ex__  s    ~~///r.   c                     | S r&   r4   )r*   memos     r+   __deepcopy__zEnum.__deepcopy__      r.   c                     | S r&   r4   r   s    r+   __copy__zEnum.__copy__  r  r.   c                     | j                   S )zThe name of the Enum member.)r   r   s    r+   rI   z	Enum.name  s     {{r.   c                     | j                   S )zThe value of the Enum member.)r   r   s    r+   r(   z
Enum.value  s     ||r.   N)r0   r1   r2   r3   r  r  r3  r,   r   r   r   r   r*  re  r)  r  ri   r  r  r   rI   r(   r4   r.   r+   r	   r	   :  s    %N r r6p ! !F  \B:6!0    r.   r	   )	metaclassc                       e Zd ZdZy)r   zS
    Only changes the repr(), leaving str() and format() to the mixed-in type.
    Nr0   r1   r2   r3   r4   r.   r+   r   r         r.   r   c                       e Zd ZdZy)r
   z8
    Enum where members are also (and must be) ints
    Nr  r4   r.   r+   r
   r
     r  r.   r
   c                   &    e Zd ZdZd Zed        Zy)r   z;
    Enum where members are also (and must be) strings
    c                    t        |      dkD  rt        d|      t        |      dk(  r$t        |d   t              st        |d   d      t        |      dk\  r$t        |d   t              st        d|d         t        |      dk(  r$t        |d   t              st        d|d   z        t        | }t        j	                  | |      }||_        |S )	z$values must already be of type `str`rx   ztoo many arguments for str(): rM   r   z is not a stringrA   zencoding must be a string, not zerrors must be a string, not %r)rG   re   rR   r   r3  r   )r  rU  r(   r   s       r+   r3  zStrEnum.__new__#  s    v;?&KLLv;!fQi-q	 DEEv;!fQi-vay STTv;!fQi- AVAY OPPVS%(r.   c                 "    | j                         S )zD
        Return the lower-cased version of the member name.
        )lower)rI   rP  r  r~  s       r+   r   zStrEnum._generate_next_value_8  s    
 zz|r.   N)r0   r1   r2   r3   r3  r   r   r4   r.   r+   r   r     s     *  r.   r   c                     | j                   S r&   rH   rf   s     r+   r"   r"   @  s    99r.   c                 >    t         | j                  | j                  ffS r&   )rT   r   r   rf   s     r+   r#   r#   E  s    T^^T[[111r.   c                   H    e Zd ZdZ e       Z e       Z e       Z e       Zy)r   a   
    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)	r0   r1   r2   r3   r   r   r   r   r   r4   r.   r+   r   r   I  s%     VFfGFE6Dr.   r   c                       e Zd ZdZeZed        Zed        Z	e	Z
ed        Zed        Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd ZeZeZeZy)r   z
    Support for flags
    c                     |s||S dS t        |      }	 t        |      }d|dz   z  S # t        $ r t        d|z        dw xY w)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
        NrM   zinvalid flag value %rrA   )max	_high_bitr   re   )rI   rP  r  r~  
last_valuehigh_bits         r+   r   zFlag._generate_next_value__  sh     !-5414%
	L ,H XaZ    	L3j@AtK	Ls	   ( Ac              #      K   t        || j                  z        D ]  }| j                  j                  |       ! yw)za
        Extract all members from the value in definition (i.e. increasing value) order.
        N)rq   r   r   r   )r  r(   vals      r+   r   zFlag._iter_member_by_value_r  s<     
 "%#//"9: 	2C((,,S11	2s   <>c              #   Z   K   t        | j                  |      d       E d{    y7 w)zI
        Extract all members from the value in definition order.
        c                     | j                   S r&   )r   )rI  s    r+   r  z+Flag._iter_member_by_def_.<locals>.<lambda>  s
    ann r.   r  N)r;  r   rX  s     r+   r   zFlag._iter_member_by_def_|  s+     
 **51, 	 	s   !+)+c                    t        |t              st        |d| j                        | j                  }| j
                  }| j                  }d}| |cxk  r|k  rn n|||z  z  r| j                  t        u rRt        |j                         |j                               }t        | d|dt        ||      dt        ||            | j                  t        u r||z  }ni| j                  t        u r|S | j                  t        u r)|dk  r>t        |dz   d|j                         z        |z   }nt        | d	| j                        |dk  r
|}|dz   |z   }|| z  }|| z  }||z  }	|r<| j                  t        ur*t        | j                  d
|d|dt        |      d      | j                   t"        u rt"        j%                  |       }
n| j                   j%                  | |      }
t'        |
d      s||
_        |	s|r=g }d}| j+                  |	      D ]"  }|j-                  |       ||j(                  z  }$ |rv|	|z  }| j.                  j1                         D ]T  \  }}||vs|j(                  s|j(                  |z  |j(                  k(  s5|j-                  |       ||j(                  z  }V ||z  }dj3                  |D cg c]  }|j4                   c}      |
_        |sd|
_        nU|r"| j                  t        u rt        | d|      |r/|
xj4                  d| j7                  |      z  z  c_        nd|
_        | j8                  j;                  ||
      }
||
| j8                  |<   |
S c c}w )z
        Create a composite member containing all canonical members present in `value`.

        If non-member values are present, result depends on `_boundary_` setting.
        r  Nz invalid value z
    given z
  allowed r   rM   rA   z unknown flag boundary (z) -->  unknown values z []r   |z: no members with value z|%s)rR   r   rn   r2   r   r   r   r'  r   r  rz   r|   r   r   r   r0   r   r   r3  r<   r   r   r   r   r   r   r   r   r   r   )r  r(   	flag_masksingles_maskall_bits	neg_valuer~   unknownaliasesr  pseudo_memberr  combined_valuerI  r$  pms                   r+   r   zFlag._missing_  sd    %%.3S5E5EF  OO	))>>	I2(2Hy01~~'u//193G3G3IJ E8(<c)X>V  7*	)5(4'19
A0@0@0B,CD#$ 
 !9<cnnO  19IqL5(E9*$<-'|+s~~T1||UGS\C 
 &"NN3/M--55c5AM}i0$)M!7GN&&|4 ,q!!))+, $w. --335 5EAr(RZZBJJ<NRTR\R\<\r*&"**45 n,G#&88w,G!QXX,G#HM !'+$S^^v5 3!PQQ$$0B0B70K(KK$#'M  ..99%O 0=C""9- -Hs   M:c                     t        || j                        s8t        dt        |      j                  d| j                  j                        |j
                  | j
                  z  |j
                  k(  S )zP
        Returns True if self has at least the same flags set as other.
        z&unsupported operand type(s) for 'in':  and )rR   r   re   rS   r2   r   )r*   others     r+   rY  zFlag.__contains__  s^     %0K,,dnn.I.IKL L }}t||+u}}<<r.   c              #   V   K   | j                  | j                        E d{    y7 w)z4
        Returns flags in definition order.
        N)r   r   r   s    r+   r^  zFlag.__iter__  s       %%dll333s   )')c                 6    | j                   j                         S r&   )r   	bit_countr   s    r+   r_  zFlag.__len__  s    ||%%''r.   c                     | j                   j                  }| j                   j                  xs t        }| j                  d|d || j
                        dS d|d| j                  d || j
                        dS )Nr  r  r  rQ   )r   r0   r&  r#  r   r   )r*   rV   r  s      r+   r   zFlag.__repr__  sd    >>**,,4;;!)6$,,+?@@  %-dkk6$,,;OPPr.   c                     | j                   j                  }| j                  |d| j                  dS |d| j                  S )Nr  )rQ   )r   r0   r   r   r*   rV   s     r+   r*  zFlag.__str__  s9    >>**;;'66&44r.   c                 ,    t        | j                        S r&   )boolr   r   s    r+   rN  zFlag.__bool__  s    DLL!!r.   c                     t        || j                        r|j                  S | j                  t        urt        || j                        r|S t
        S r&   )rR   r   r   r   r   NotImplemented)r*   flags     r+   
_get_valuezFlag._get_value  sB    dDNN+<<v-*T4CUCU2VKr.   c                     | j                  |      }|t        u rt        S | |fD ]"  }| j                  |      t        d| d       | j                  }| j	                  ||z        S )N'z,' cannot be combined with other flags with |r  r  re   r   r   r*   r  other_valuer  r(   s        r+   r,  zFlag.__or__  v    ooe,.(!!%K 	XDt$,!D6)U VWW	X ~~ek122r.   c                     | j                  |      }|t        u rt        S | |fD ]"  }| j                  |      t        d| d       | j                  }| j	                  ||z        S )Nr  z,' cannot be combined with other flags with &r  r  s        r+   r-  zFlag.__and__  r  r.   c                     | j                  |      }|t        u rt        S | |fD ]"  }| j                  |      t        d| d       | j                  }| j	                  ||z        S )Nr  z,' cannot be combined with other flags with ^r  r  s        r+   r.  zFlag.__xor__%  r  r.   c                 X   | j                  |       t        d|  d      | j                  s| j                  t        t
        fv r-| j                  | j                         | _        | j                  S | j                  | j                  | j                   z        | _        | j                  S )Nr  z' cannot be inverted)	r  re   r(  r'  r   r   r   r   r   r   s    r+   r2  zFlag.__invert__0  s    ??4 (av%9:;;??"5$-/"&..$,,"?  #'..1D1D}1T"Ur.   N)r0   r1   r2   r3   r#  r   r   r   r  r   r   r   r   rY  r^  r_  r   r*  rN  r  r,  r-  r.  r2  r0  r/  r1  r4   r.   r+   r   r   X  s     N! !$ 2 2 +M  Z Zx=4(Q5"	3	3	3	 HGHr.   r   rx  c                       e Zd ZdZy)r   z)
    Support for integer-based Flags
    Nr  r4   r.   r+   r   r   @  r  r.   r   c                 (    | j                         dz
  S )zJ
    returns index of highest bit, or -1 if value is zero or negative
    rM   )rz   r'   s    r+   r  r  F  s     !!r.   c           	      ,   g }| j                   j                         D ]2  \  }}||j                  k7  s|j                  ||j                  f       4 |r:dj	                  |D cg c]  \  }}|d| c}}      }t        d| d|      | S c c}}w )zI
    Class decorator for enumerations ensuring unique member values.
    ,  -> zduplicate values found in r  )r`  r   rI   r   r   rn   )enumeration
duplicatesrI   r   aliasalias_detailss         r+   r   r   L  s     J#//557 3f6;;tV[[123 		AKLud+LNm- . 	. Ms   $B
c                 p      j                   dj                   fdj                         D              S )Nr  c              3   ^   K   | ]$  }|   j                   r|d t        |       & yw)=N)r#  rT   )r   kdcfr*   s     r+   r   z"_dataclass_repr.<locals>.<genexpr>]  s0      1v{{ '$*+s   *-)r  r   r  )r*   r  s   `@r+   r  r  [  s2    

#
#C99 XXZ  r.   c                 t    | j                   j                  j                  d      d   }|d| j                  S )z{
    use module.enum_name instead of class.enum_name

    the module is the last module in case of a multi-module name
    rQ   rL   )r   r1   r   r   )r*   rO  s     r+   r   r   c  s2     ^^&&,,S1"5Fdkk**r.   c                    | j                   j                  j                  d      d   }| j                   j                  }| j                  |d|d| j
                  dS t        | j
                        r|d| j                  S | j                  t        j                  ur=dj                  | j                  j                  d      D cg c]	  }|d| c}      S g }| j                  j                  d      D ]=  }|d   j                         r|j                  |       (|j                  |d|       ? dj                  |      S c c}w )z{
    use module.flag_name instead of class.flag_name

    the module is the last module in case of a multi-module name
    rQ   rL   r  r  r  r   )r   r1   r   r0   r   r   rb   r'  r   r   r   rI   isdigitr   )r*   rO  rV   rI   r$  s        r+   r   r   l  s    ^^&&,,S1"5F~~&&H{{$h==dll# $++..l///xxdiiooc>RSdFD1STT""3' 	3At||~Avq12		3
 xx~ Ts   
Ec                     | j                   (| j                  j                  }|d| j                  dS | j                   S )z2
    use enum_name instead of class.enum_name
    r  r  )r   r   r0   r   r  s     r+   r   r     s6     {{>>**#T\\22{{r.   c                    t        | t              rt        | _        nt        | _        t        | t
              r|rt        | _        t        j                  | j                     j                  j                  | 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
    )r   r   r   r   r   r   r   r*  ry  r  r1   r   r  r`  )r  
update_strs     r+   r   r     sY     #t''c8$
 KK((//@Jr.   )r  rA  c                      fd}|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
        <enum 'Color'>
    c                    | j                   }j                  | j                  j                  d      }||j                  }nj
                  j                  }i }i }|||d<   ||d<   |d<   j                  x|d<   }g x|d<   }i x|d<   }i x|d<   }	g |d	<   j
                  x|d
<   }
j                  |d<   t        t              rxs j                  |d<   d |d<   d |d<   d |d<   d |d<   t        j                  |d<   t        j                  |d<   t        j                  |d<   t        j                  |d<   t        j                   |d<   t        j"                  |d<   t        j$                  |d<   | j                  j'                         D ]B  \  }}|dv rt)        |      s"t+        ||      st-        |      st/        |      r|||<   >|||<   D | j                  j                  d      d|d<   t1        |f|d      }dD ]O  }||vst3        |      }t3        ||      }t3        t4        |      }t3        |
|      }|||fv sCt7        |||       Q g }t        |t              rdx}}|j'                         D ]U  \  }}t9        |t:              r*t:        j<                  t>        u r ||dtA        |      |      }||	v r;|	|   }tC               }||_"        |jG                  ||       t7        |||       |||<   r"t9        |tH              s|f} ||g| }|d   }n ||      }|||_%        ||_&        ||_'        |jQ                  |       tC               }||_"        |jG                  ||       t7        |||       |||<   tA        |      |_)        ||	|<   tU        |      r|jW                  |       ||z  }n||z  }|jW                  |       X ||z  |_,        ||_-        d ||z  j]                         z  dz
  |_/        |D cg c]  }|jJ                   }}|ta        |      k7  rs|jb                  |_2        n`|j'                         D ]L  \  }}t9        |t:              r7|j<                  t>        u r ||dtA        |      |      |_        |j<                  }||	v r;|	|   }tC               }||_"        |jG                  ||       t7        |||       |||<   r"t9        |tH              s|f} ||g| }|d   }n ||      }|||_%        ||_&        ||_'        |jQ                  |       tA        |      |_)        tC               }||_"        |jG                  ||       t7        |||       |||<   ||	|<   |jW                  |       |jW                  |       O d|v r|j                  |_3        th        j                  |_        |S c c}w )!Nr3  r:  r   r   r   r   r   r   r   r   r&  r'  r   r   r   r(  r,  r.  r-  r/  r1  r0  r2  )r   __weakref__r3   zAn enumeration.Tr  r+  r   rM   rA   )5r0   r   r   r   r   r   r3  r   r&  r   r   r'  r,  r.  r-  r/  r1  r0  r2  r   rJ   r_   rN   r>   rS   rT   r   rk   rR   r   r(   r   rG   r   r   r   r   r   r   r   r,   r   rb   r   r   r   rz   r   r;  r   r   r:  r	   )r  rV   r3  
new_memberattrsr  gnvr>  rv  value2member_mapr  rI   r=   r   rE  rF  rG  rH  gnv_last_valuessingle_bits
multi_bitsr(   r   r   rI  rJ  r  r  rA  s                             r+   convert_classz#_simple_enum.<locals>.convert_class  s   <<''H,,""9- ))J,,44J%/D!")^%\.3.I.II$%022,..^z8::!"%5&("#.3.A.AA_$11^eT"!)!=U-=-=D"&D!%D%)D!"!%D![[DN"llDO"llDO"llDO#}}D#}}D!%D++- 	"ID#22$;x#>*TBRVdehVi T
!d	" <<I&./DO (UIthPTU
J 	;D4%eT2&z48 ' 5#*;#= $4m#DDJk:	; j$''((K*${{} &2eeT*tzzZ/Ga\):OLE,,-e4F'zH&,HO))*d;Jh7'-Jt$  )%7%*IE!+J!?!? %a!+J!7).$(FM*4F'OOE*'zH&,HO))*d;Jh7'-Jt$*-l*;F'.4$U+%e,$++D1#u,"e+
#**51M&2N &1:%=J"(3J%$%;z+A*M*M*O$PST$TJ!.891999K9f[11+5+J+J
(  %{{} #2eeT*{{j0&)$3|3Do&V!KKE,,-e4F'zH&,HO))*d;Jh7'-Jt$  )%7%*IE!+J!?!? %a!+J!7).$(FM*4F'OOE**-l*;F''zH&,HO))*d;Jh7'-Jt$.4$U+ ''-#**51G#2H (2(:(:J%!\\
Y :s   Wr4   )r  r  rA  r#  s   ``` r+   r  r    s     Wp r.   c                       e Zd ZdZdZdZdZy)r   z8
    various conditions to check an enumeration for
    zno skipped integer valuesz0multi-flag aliases may not contain unnamed flagszone name per valueN)r0   r1   r2   r3   r   r    r!   r4   r.   r+   r   r   F  s     -JDK!Fr.   r   c                       e Zd ZdZd Zd Zy)r   zG
    Check an enumeration for various constraints. (see EnumCheck)
    c                     || _         y r&   )checks)r*   r'  s     r+   r,   zverify.__init__U  s	    r.   c                 <   | j                   }|j                  }t        t        |t              rd}nt        |t              rd}nt        d      |D ]  }|t        u rg }|j                  j                         D ]2  \  }}||j                  k7  s|j                  ||j                  f       4 |s`dj                  |D 	cg c]  \  }	}|	d| c}}	      }
t        d|d|
      |t        u rt        d |D              }t        |      d	k  rt!        |      t#        |      }}g }|dk(  rCt%        t'        |      d
z   t'        |            D ]  }d	|z  |vs|j                  d	|z           n>|dk(  r+t%        |d
z   |      D ]  }||vs|j                  |        nt)        d|z        |set        d|d|ddj                  d |D              d d       |t*        u s|j,                  }|D cg c]  }|j.                   }}g }d}|j0                  j                         D ]s  \  }}	||v r|	j.                  dk  rt3        t5        |	j.                              }|D cg c]	  }||vs| }}|sP|j                  |       |t7        t8        |      z  }u |sYt        |      d
k(  r	d|d   z  }	nddj                  |d d       d|d   d}	t;        |      rd|z  }nd|z  }t        d|d|	d|d       |S c c}}	w c c}w c c}w )Nr  r   z4the 'verify' decorator only works with Enum and Flagr  r	  zaliases found in r  c              3   4   K   | ]  }|j                     y wr&   r'   )r   rB  s     r+   r   z"verify.__call__.<locals>.<genexpr>m  s     :QWW:s   rA   rM   zverify: unknown type %rzinvalid ry   z: missing values c              3   2   K   | ]  }t        |        y wr&   )r   )r   rI  s     r+   r   z"verify.__call__.<locals>.<genexpr>  s     ;TqCF;Tr%     r   zalias %s is missingzaliases rL   r  z are missingz
value 0x%xzcombined values of 0x%xzinvalid Flag z/ [use enum.show_flag_values(value) for details])r'  r0   r   r   r	   re   r!   r`  r   rI   r   r   rn   r   r   rG   minr  ranger  r   r    r   r(   r   rs   rq   r   _or_rb   )r*   r
  r'  rV   	enum_typecheckr  rI   r   r  r  rU  lowhighmissingr   r>  rI  member_valuesmissing_namesmissing_valuer   missedr(   s                           r+   rV  zverify.__call__W  sH   ''
; =IT*IRSS C	E
$/$;$;$A$A$C ?LD&v{{*"))4*=>? $(IIMWXMUD5$7X%ZM$(-&9 : :*$:k::v;?KVT&"9S>!#3Yt_E 1a4v-#NN1a401 &("3q5$/ .F?#NN1-. $$=	$IJJ$%x;TG;T1U'W"s&$ % % +%*992= >Q > > " !#.#;#;#A#A#C >KD%|+ {{Q !."=>F)/JA1M3IaJFJ%,,T2%f)==> !=)Q. 5a8H H / !%		-*< =}R?P!" &m4 ,} < 9M I$'7 AC	H w Y: !? Ks   L>L.	L8LN)r0   r1   r2   r3   r,   rV  r4   r.   r+   r   r   Q  s    Mr.   r   c           
      \   g }| j                   |j                   k7  rq| j                   }t        |j                               }|j                   }t        |j                               }t        t        | j                  j                               t        |j                  j                               z         }t        ||z         D ]  }|dv r	||v r||vr|j                  d|       '||vr|j                  d|       @||   }	||   }
t        |	      st        |	t        j                        rp|dk(  rj|	j                  dd      j                  dd      }|
j                  dd      j                  dd      }||k7  s|j                  |dd	|	d
d|
       |	|
k7  s|j                  |dd	|	d
d|
        |j                          |D ]/  }g }||vr|j                  d|z         n||vr|j                  d|z         n| |   j                   }t        |j                               }||   j                   }t        |j                               }t        ||z         D ]n  }|dv r||vr|j                  d|d|       $||vr|j                  d|d|       @||   }	||   }
|	|
k7  sP|j                  |dd|	d
d|
       p |s|j                  |ddj                  |             2 dD ]x  }||v r||v r||vri||vret        | |d      }t        ||d      }t        |d      r|j                  }|j                  }||k7  sX|j                  |dd	|ddd|       yz |rt!        ddj                  |      z        y)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.
    )r1   r   r   r3   zmissing key: zextra key:   r3   ry   rP   	z:
         zchecked -> z

         zsimple  -> z#missing member from simple enum: %rzextra member in simple enum: %r)r1   r   r(  zmissing key z not in the simple enum member z
extra key z in simple enum member zchecked member -> zsimple member  -> z member mismatch:
      z
      )r*  r   ri   r)  __getnewargs_ex____getnewargs__ri   
__reduce__Nr   z:  30z
simple -> zenum mismatch:
   %sz
   )r   rs   r  r   r   r   callablerR   r{   r   r}   r  r   rT   r<   r   re   )checked_enumsimple_enumfailedchecked_dictchecked_keyssimple_dictsimple_keysr>  r  checked_valuesimple_valuecompressed_checked_valuecompressed_simple_valuerI   failed_memberchecked_member_dictchecked_member_keyssimple_member_dictsimple_member_keysrD  checked_methodsimple_methods                         r+   _test_simple_enumrQ    s   & F 4 44#,,L--/0!**;++-.\..3356{//44678 |k12 	CUU$K'39:L(39: ,S 1*3/M*j.W)#/</D/DS/L/T/TUYZ\/],.:.B.B3r.J.R.RSWXZ.[+/3JJ #3@ C3? B'" #
 #l2MM/<?/;># 7	@ 	  	DM;&CdJK\)?$FG&24&8&A&A#&*+>+C+C+E&F#%0%6%?%?"%)*<*A*A*C%D"25GGH 'CJJ $66%,,begk-lm$77%,,X[]a-bc(;C(@'9#'>(L8)00$'>K$N>J$M2& ''" joom< ;	@ 	F $<)?{*v\/I!(vt!D 'VT B>:6%3%<%<N$1$:$:M!]2MM"/=@.;>#  /	0 /',,v2FFGG r.   c                Z   t         j                  |   j                  }|r|j                  }n|}|j                         D cg c]  \  }} ||      r||f }}}	 |j	                  d         | |||xs t              }	|	S c c}}w # t
        $ r |j	                  d        Y :w xY w)zS
    Create a new Enum subclass that replaces a collection of global constants
    c                     | d   | d   fS r  r4   r  s    r+   r  z_old_convert_.<locals>.<lambda>6  s    AaD!A$< r.   r  c                     | d   S r  r4   r  s    r+   r  z_old_convert_.<locals>.<lambda>9  s
    1Q4 r.   )rO  r  )ry  r  r   r   r  re   r   )
r  rI   rO  r  r  r  r  r(   r  r  s
             r+   _old_convert_rU    s     [[(11N  &||~ed| 5MG )/0 gfx7G4
HCJ  )()s   BB B*)B*r&   )F)Dry  builtinsr{   typesr   r   operatorr   r.  	functoolsr   __all__r	   r   r   _stdlib_enumsr   r   r   r   r>   rJ   rN   rZ   r_   rb   rl   rq   rt   r|   r   r   r   r   r   r   rj   r   rS   r   r   r   r
   r   r   r"   _reduce_ex_by_global_namer#   r   r   r   r   r   r  r   r  r   r   r   r   r  r   r   r    r!   r   rQ  rU  r4   r.   r+   <module>r]     s   
  9   
 26 5 5t 5e 5mh V 		A0
'$0  \
  \
' '6+$ 6+r9 9DA AHz+t z+v UX Upt c8 c8 D 2 27   , e4& ePc8TD "+.  h hT g" " " #, 
KS SjwHr < ')r.   