Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/enum.cpython-37.pyc

B

� f��@s&ddlZddlmZmZyddlmZWn ek
rHddlmZYnXdddddd	d
gZdd�Z	d
d�Z
dd�Zdd�Ze
�ZGdd	�d	�ZGdd�de�ZdZGdd�de�ZGdd�ded�ZGdd�dee�Zdd�ZGdd�de�ZGdd�dee�Zdd�Zd d
�Zd!d"�Zd#d$�ZdS)%�N)�MappingProxyType�DynamicClassAttribute)�OrderedDict�EnumMeta�Enum�IntEnum�Flag�IntFlag�auto�uniquecCst|d�pt|d�pt|d�S)z5Returns True if obj is a descriptor, False otherwise.�__get__�__set__�
__delete__)�hasattr)�obj�r�)/opt/alt/python37/lib64/python3.7/enum.py�_is_descriptors

rcCsLt|�dkoJ|dd�|dd�ko.dknoJ|ddkoJ|ddkS)z3Returns True if a __dunder__ name, False otherwise.�N�����__�_���)�len)�namerrr�
_is_dunders(rcCsLt|�dkoJ|d|dko&dknoJ|dd�dkoJ|dd�dkS)z1Returns True if a _sunder_ name, False otherwise.rr���r�r)r)rrrr�
_is_sunder"s rcCsdd�}||_d|_dS)z"Make the given class un-picklable.cSstd|��dS)Nz%r cannot be pickled)�	TypeError)�self�protorrr�_break_on_call_reduce,sz6_make_class_unpicklable.<locals>._break_on_call_reducez	<unknown>N)�
__reduce_ex__�
__module__)�clsr#rrr�_make_class_unpicklable*sr'c@seZdZdZeZdS)r
zP
    Instances are replaced with an appropriate value in Enum class suites.
    N)�__name__r%�__qualname__�__doc__�
_auto_null�valuerrrrr
2scs,eZdZdZ�fdd�Z�fdd�Z�ZS)�	_EnumDictz�Track enum member order and ensure member names are not reused.

    EnumMeta will use the names found in self._member_names as the
    enumeration member names.

    cs&t���g|_g|_g|_d|_dS)NF)�super�__init__�
_member_names�_last_values�_ignore�_auto_called)r!)�	__class__rrr/@s

z_EnumDict.__init__csdt|�r�|dkrtd��|dkr<|jr.td��t|d|�nV|dkr�t|t�r`|�dd���}nt	|�}||_
t|�t|j�@}|r�td	|f��n�t
|�r�|d
kr�d}n�||jkr�td|��n�||j
kr�n�t|��sR||kr�td
|||f��t|t��r:d|_|jtk�r4|�|dt|j�|jdd��|_|j}|j�|�|j�|�t��||�dS)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.

        )�_order_�_create_pseudo_member_�_generate_next_value_�	_missing_�_ignore_z(_names_ are reserved for future Enum user7z4_generate_next_value_ must be defined before members�_generate_next_valuer9�,� z-_ignore_ cannot specify already set names: %r�	__order__r5zAttempted to reuse key: %rz%r already defined as: %rTrN)r�
ValueErrorr3r �setattr�
isinstance�str�replace�split�listr2�setr0rrr
r,r+r:rr1�appendr.�__setitem__)r!�keyr,�already)r4rrrGGsD	



"z_EnumDict.__setitem__)r(r%r)r*r/rG�
__classcell__rr)r4rr-9sr-cs�eZdZdZedd��Z�fdd�Zdd�Zd)dddd	d
�dd�Zd
d�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��Zdd�Zdd �Z�fd!d"�Zdddd	d
�d#d$�Zed%d&��Zed'd(��Z�ZS)*rzMetaclass for EnumcCs0t�}|�|�\}}|dk	r,t|dd�|d<|S)Nr7)r-�_get_mixins_�getattr)�metaclsr&�bases�	enum_dict�member_type�
first_enumrrr�__prepare__�s
zEnumMeta.__prepare__c	s"��dg��d��d}x|D]}��|d�q W|�|�\�}|���|�\}}}	�fdd��jD�}
x�jD]
}�|=qrW��dd�}t|
�ddh@}
|
r�td�d�	|
����d	�kr�d
�d	<t
��|||��}g|_t
�|_�|_dd�|��D�}i|_d
�k�r:�tk	�r:d}t�fdd�|D���s:t|��x6�jD�]*}|
|}t|t��sf|f}n|}�tk�rz|f}|	�s�||�}t|d��s�||_n6||f|��}t|d��s҈tk�r�||_n
�|�|_|j}||_||_|j|�x8|j��D]\}}|j|jk�r�|}P�q�W|j�|�||k�r>t|||�||j|<y||j|<Wntk
�rlYnX�qDWxPdD]H}t||�}t�|d�}t||d�}|dk	�rz||k�rzt|||��qzWt dk	�r�|�r�||_!t j|_|dk	�rt|t"��r
|�#dd��$�}||jk�rtd��|S)Nr9csi|]}�||�qSrr)�.0�k)�	classdictrr�
<dictcomp>�sz$EnumMeta.__new__.<locals>.<dictcomp>r5�mro�zInvalid enum member name: {0}r;r*zAn enumeration.cSs.h|]&}|j��D]\}}t|t�r|�qqSr)�__dict__�itemsr@r)rS�crT�vrrr�	<setcomp>�sz#EnumMeta.__new__.<locals>.<setcomp>r$)�__getnewargs_ex__�__getnewargs__r$�
__reduce__c3s|]}|�jkVqdS)N)rY)rS�m)rPrr�	<genexpr>�sz#EnumMeta.__new__.<locals>.<genexpr>�_value_)�__repr__�__str__�
__format__r$r<z#member order does not match _order_)%�
setdefaultrF�poprK�
_find_new_r0rEr>�format�joinr.�__new__�_member_names_r�_member_map_�
_member_type_rW�_value2member_map_�object�anyr'r@�tuplerrc�_name_�__objclass__r/rZr?r rLr�__new_member__rArBrC)rMr&rNrU�ignorerHrQrl�save_new�use_args�enum_membersrr5�
invalid_names�
enum_class�dynamic_attributes�methods�member_namer,�args�enum_member�canonical_member�class_method�
obj_method�enum_method)r4)rUrPrrl�s�













zEnumMeta.__new__cCsdS)z6
        classes/types should always be True.
        Tr)r!rrr�__bool__szEnumMeta.__bool__Nr)�module�qualname�type�startcCs*|dkr|�||�S|j||||||d�S)aEither 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')).

        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.

        N)r�r�r�r�)rl�_create_)r&r,�namesr�r�r�r�rrr�__call__!szEnumMeta.__call__cCs6t|t�s ddl}|�dtd�t||�o4|j|jkS)NrzHusing non-Enums in containment checks will raise TypeError in Python 3.8r)r@r�warnings�warn�DeprecationWarningrtrn)r&�memberr�rrr�__contains__?s
zEnumMeta.__contains__cs(||jkrtd|j��t��|�dS)Nz%s: cannot delete Enum member.)rn�AttributeErrorr(r.�__delattr__)r&�attr)r4rrr�Hs
zEnumMeta.__delattr__cCsddddg|jS)Nr4r*�__members__r%)rm)r!rrr�__dir__Ps
zEnumMeta.__dir__cCs>t|�rt|��y
|j|Stk
r8t|�d�YnXdS)a5Return the enum member matching `name`

        We use __getattr__ instead of descriptors or inserting into the enum
        class' __dict__ in order to support `name` and `value` being both
        properties for enum members (which live in the class' __dict__) and
        enum members themselves.

        N)rr�rn�KeyError)r&rrrr�__getattr__Ts	
zEnumMeta.__getattr__cCs
|j|S)N)rn)r&rrrr�__getitem__dszEnumMeta.__getitem__cs�fdd��jD�S)Nc3s|]}�j|VqdS)N)rn)rSr)r&rrrbhsz$EnumMeta.__iter__.<locals>.<genexpr>)rm)r&r)r&r�__iter__gszEnumMeta.__iter__cCs
t|j�S)N)rrm)r&rrr�__len__jszEnumMeta.__len__cCs
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.

        )rrn)r&rrrr�mszEnumMeta.__members__cCs
d|jS)Nz	<enum %r>)r()r&rrrrdwszEnumMeta.__repr__cs�fdd�t�j�D�S)Nc3s|]}�j|VqdS)N)rn)rSr)r&rrrb{sz(EnumMeta.__reversed__.<locals>.<genexpr>)�reversedrm)r&r)r&r�__reversed__zszEnumMeta.__reversed__cs0|j�di�}||krtd��t��||�dS)z�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.

        rnzCannot reassign members.N)rY�getr�r.�__setattr__)r&rr,�
member_map)r4rrr�}szEnumMeta.__setattr__c
Cs�|j}|dkr|fn||f}|�|�\}	}
|�||�}t|t�rP|�dd���}t|ttf�r�|r�t|dt�r�|g}}g}
xDt	|�D]8\}}|
�
||||
dd��}|
�|�|�||f�q�Wx6|D].}t|t�r�|||}}n|\}}|||<q�W|�||||�}|dk�rVyt
�d�jd}Wn*tttfk
�rT}zWdd}~XYnX|dk�rjt|�n||_|dk	�r�||_|S)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;r<rrr()r4rKrRr@rArBrCrsrD�	enumerater7rFrl�sys�	_getframe�	f_globalsr�r>r�r'r%r))r&�
class_namer�r�r�r�r�rMrNrrQrU�original_names�last_values�countrr,�itemr�member_valuer|�excrrrr��s<
 







zEnumMeta._create_cCsP|sttfSdd�}|d}t|t�s.td��||�p8t}|jrHtd��||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__

        cSsHxB|D]:}x4|jD]*}|tkr"qqd|jkrt|t�r8q|SqWqWdS)Nrl)�__mro__rqrY�
issubclassr)rN�chain�baserrr�_find_data_type�s


z.EnumMeta._get_mixins_.<locals>._find_data_typerzZnew enumerations should be created as `EnumName([mixin_type, ...] [data_type,] enum_type)`zCannot extend enumerations)rqrr�r rm)rNr�rQrPrrrrK�s
zEnumMeta._get_mixins_c	Cs�|�dd�}|dk	}|dkrtxVdD]H}x8||fD],}t||d�}|ddjtjtjhkr0|}Pq0W|dk	r"Pq"Wtj}|tjkr�d}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__

        rlN)rvrlFT)r�rLrlrqr)	rUrPrQrlrx�method�possible�targetryrrrri�s(


zEnumMeta._find_new_)N)r(r%r)r*�classmethodrRrlr�r�r�r�r�r�r�r�r��propertyr�rdr�r�r��staticmethodrKrirJrr)r4rr�s(
	

5 c@s�eZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zeddd��ZdS)rzRGeneric enumeration.

    Derive from this class to define new enumerations.

    c
Cst|�|kr|Sy
|j|Stk
r.Yn6tk
rbx |j��D]}|j|krH|SqHWYnXyd}|�|�}Wn*tk
r�}z|}d}Wdd}~XYnXt	||�r�|St
d||jf�}|dkr�|dkr�|�n|dkr�td|j|f�}||_|�dS)Nz%r is not a valid %szDerror in %s._missing_: returned %r instead of None or a valid member)
r�rpr�r rn�valuesrcr8�	Exceptionr@r>r(�__context__)r&r,r�r��result�e�ve_excrrrrls6


zEnum.__new__c	Cs8x2t|�D]"}y|dStk
r*Yq
Xq
W|SdS)Nr)r�r )rr�r�r��
last_valuerrrr7;s
zEnum._generate_next_value_cCstd||jf��dS)Nz%r is not a valid %s)r>r()r&r,rrrr8DszEnum._missing_cCsd|jj|j|jfS)Nz<%s.%s: %r>)r4r(rtrc)r!rrrrdHsz
Enum.__repr__cCsd|jj|jfS)Nz%s.%s)r4r(rt)r!rrrreLszEnum.__str__cs&�fdd��j��D�}dddg|S)Ncs2g|]*}|jD]}|ddkr|�jkr|�qqS)rr)rYrn)rSr&ra)r!rr�
<listcomp>Qs
z Enum.__dir__.<locals>.<listcomp>r4r*r%)r4rW)r!�added_behaviorr)r!rr�Os
zEnum.__dir__cCs0|jtkrt}t|�}n|j}|j}|�||�S)N)rorqrArcrf)r!�format_specr&�valrrrrfXs

zEnum.__format__cCs
t|j�S)N)�hashrt)r!rrr�__hash__gsz
Enum.__hash__cCs|j|jffS)N)r4rc)r!r"rrrr$jszEnum.__reduce_ex__cCs|jS)zThe name of the Enum member.)rt)r!rrrrtsz	Enum.namecCs|jS)zThe value of the Enum member.)rc)r!rrrr,ysz
Enum.valueNcs�ttj|�}�rt���n|���fdd����D�}y|jdd�d�Wn$tk
rp|jdd�d�YnX||||d�}t|_|�|j	�|||<|S)z[
        Create a new Enum subclass that replaces a collection of global constants
        cs g|]}�|�r|�|f�qSrr)rSr)�filter�sourcerrr��sz!Enum._convert.<locals>.<listcomp>cSs|d|dfS)Nrrr)�trrr�<lambda>��zEnum._convert.<locals>.<lambda>)rHcSs|dS)Nrr)r�rrrr��r�)r�)
�varsr��modules�keys�sortr �_reduce_ex_by_namer$�updater�)r&rr�r�r��module_globals�membersr)r�r�r�_convert~s

z
Enum._convert)N)r(r%r)r*rlr7r�r8rdrer�rfr�r$rrr,r�rrrrr
s(		
)�	metaclassc@seZdZdZdS)rz.Enum where members are also (and must be) intsN)r(r%r)r*rrrrr�scCs|jS)N)r)r!r"rrrr��sr�c@speZdZdZdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)rzSupport for flagsc	Csd|s|dk	r|SdSxBt|�D]6}yt|�}PWqtk
rRtd|�d�YqXqWd|dS)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_value: the last value assigned or None
        NrzInvalid Flag value: %rr)r��	_high_bitr�r )rr�r�r�r��high_bitrrrr7�s	zFlag._generate_next_value_cCs.|}|dkr|}|�|�}|dkr*|}|S)Nr)r6)r&r,�original_value�possible_memberrrrr8�s
zFlag._missing_cCsb|j�|d�}|dkr^t||�\}}|r:td||jf��t�|�}d|_||_|j�	||�}|S)zL
        Create a composite member iff value contains only members.
        Nz%r is not a valid %s)
rpr��
_decomposer>r(rqrlrtrcrg)r&r,�
pseudo_memberr�extra_flagsrrrr6�s
zFlag._create_pseudo_member_cCs8t||j�s&ddl}|�dtd�dS|j|j@|jkS)NrzHusing non-Flags in containment checks will raise TypeError in Python 3.8rF)r@r4r�r�r�rc)r!�otherr�rrrr��szFlag.__contains__cCsV|j}|jdk	r$d|j|j|jfSt||j�\}}d|jd�dd�|D��|jfS)Nz<%s.%s: %r>�|cSsg|]}t|jp|j��qSr)rArtrc)rSrarrrr��sz!Flag.__repr__.<locals>.<listcomp>)r4rtr(rcr�rk)r!r&r��	uncoveredrrrrd�s
z
Flag.__repr__cCs�|j}|jdk	r d|j|jfSt||j�\}}t|�dkr^|djdkr^d|j|djfSd|jd�dd�|D��fSdS)Nz%s.%srrz%s.%rr�cSsg|]}t|jp|j��qSr)rArtrc)rSrarrrr��sz Flag.__str__.<locals>.<listcomp>)r4rtr(r�rcrrk)r!r&r�r�rrrre�s
zFlag.__str__cCs
t|j�S)N)�boolrc)r!rrrr�sz
Flag.__bool__cCs"t||j�stS|�|j|jB�S)N)r@r4�NotImplementedrc)r!r�rrr�__or__szFlag.__or__cCs"t||j�stS|�|j|j@�S)N)r@r4r�rc)r!r�rrr�__and__szFlag.__and__cCs"t||j�stS|�|j|jA�S)N)r@r4r�rc)r!r�rrr�__xor__
szFlag.__xor__cCsRt|j|j�\}}|�d�}x*|jD] }||kr$|j|j@s$||B}q$W|�|�S)Nr)r�r4rc)r!r�r��invertedrarrr�
__invert__s
zFlag.__invert__N)r(r%r)r*r7r�r8r6r�rdrer�r�r�r�r�rrrrr�s


c@sTeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	eZ
eZe	Zdd
�Z
dS)r	zSupport for integer-based FlagscCs*t|t�std||jf��|�|�}|S)Nz%r is not a valid %s)r@�intr>r(r6)r&r,�
new_memberrrrr8s

zIntFlag._missing_cCs�|j�|d�}|dkr�|g}t||�\}}xL|rvt|�}d|}||jkr\||kr\|�|�||krld}q,||N}q,Wx6t|�D]*}t�||�}d|_||_	|j�
||�}q�W|S)Nrr)rpr�r�r�rFr�r�rlrtrcrg)r&r,r��need_to_createrr��bit�
flag_valuerrrr6%s&


zIntFlag._create_pseudo_member_cCs0t||jtf�stS|�|j|�|�jB�}|S)N)r@r4r�r�rc)r!r�r�rrrr�CszIntFlag.__or__cCs,t||jtf�stS|�|j|�|�j@�S)N)r@r4r�r�rc)r!r�rrrr�IszIntFlag.__and__cCs,t||jtf�stS|�|j|�|�jA�S)N)r@r4r�r�rc)r!r�rrrr�NszIntFlag.__xor__cCs|�|j�}|S)N)r4rc)r!r�rrrr�WszIntFlag.__invert__N)r(r%r)r*r�r8r6r�r�r��__ror__�__rand__�__rxor__r�rrrrr	scCs|��dS)z@returns index of highest bit, or -1 if value is zero or negativer)�
bit_length)r,rrrr�\sr�cCsbg}x0|j��D]"\}}||jkr|�||jf�qW|r^d�dd�|D��}td||f��|S)z?Class decorator for enumerations ensuring unique member values.z, cSsg|]\}}d||f�qS)z%s -> %sr)rS�aliasrrrrr�hszunique.<locals>.<listcomp>z duplicate values found in %r: %s)r�rZrrFrkr>)�enumeration�
duplicatesrr��
alias_detailsrrrr`s
cCs�|}|dk}|r*dd�t|j���D�}ndd�t|j���D�}g}x4|D],\}}|rL||@|krL|�|�||M}qLW|s�||jkr�|�|j|�|jdd�dd�t|�d	kr�|dj|kr�|�d�||fS)
z#Extract all members from the value.rcSs"g|]\}}|jdk	r||f�qS)N)r)rSr\rarrrr�xsz_decompose.<locals>.<listcomp>cSs*g|]"\}}|jdk	st|�r||f�qS)N)r�
_power_of_two)rSr\rarrrr�scSs|jS)N)rc)rarrrr��r�z_decompose.<locals>.<lambda>T)rH�reverser)rDrprZrFr�rr,rh)�flagr,�not_covered�negative�flags_to_checkr�r�r�rrrr�ms$

r�cCs|dkrdS|dt|�kS)NrFr)r�)r,rrrr��sr�)r��typesrr�_collectionsr�ImportError�collections�__all__rrrr'rqr+r
�dictr-rr�rr�rr�rr	r�rr�r�rrrr�<module>s<DqA
#

Hacked By AnonymousFox1.0, Coded By AnonymousFox