Your IP : 3.141.19.115


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/enum.cpython-36.opt-1.pyc

3

� fF��@s>ddlZddlmZmZddlmZddlmZyddl	m
Z
Wn ek
r`ddlm
Z
YnXdddd	d
ddgZ
d
d�Zdd�Zdd�Zdd�Ze�ZGdd�d�ZGdd�de�ZdZGdd�de�ZGdd�ded�ZGdd�dee�Zdd�ZGdd	�d	e�ZGdd
�d
ee�Zd d!�Zd"d�Z d#d$�Z!d%d&�Z"dS)'�N)�MappingProxyType�DynamicClassAttribute)�reduce)�or_)�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/python36/lib64/python3.6/enum.py�_is_descriptors

rcCsT|dd�|dd�ko"dknoR|dd�dkoR|dd	�dkoRt|�dkS)
z3Returns True if a __dunder__ name, False otherwise.N��__��_�������r)�len)�namerrr�
_is_dunders(rcCsL|d|dkodknoJ|dd�dkoJ|dd�dkoJt|�dkS)z1Returns True if a _sunder_ name, False otherwise.r�rr���rr!)r)rrrr�
_is_sunder$s r"cCsdd�}||_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3scs,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.

    cst�j�g|_g|_dS)N)�super�__init__�
_member_names�_last_values)r$)�	__class__rrr2As
z_EnumDict.__init__cs�t|�r.|dkrtd��|dkr�t|d|�n�t|�rD|dkr�d}n�||jkr\td|��nxt|�s�||kr�td	|||f��t|t�r�|j	t
kr�|j|d
t|j�|j
dd��|_	|j	}|jj|�|j
j|�t�j||�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_z(_names_ are reserved for future Enum use�_generate_next_value�	__order__zAttempted to reuse key: %rz%r already defined as: %rr N)r6r7r8r9)r"�
ValueError�setattrrr3r#r�
isinstancerr/r.r:rr4�appendr1�__setitem__)r$�keyr/)r5rrr@Fs,	


"z_EnumDict.__setitem__)r+r(r,r-r2r@�
__classcell__rr)r5rr0:sr0cs�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�}|j|�\}}|dk	r,t|dd�|d<|S)Nr8)r0�_get_mixins_�getattr)�metaclsr)�bases�	enum_dict�member_type�
first_enumrrr�__prepare__rs
zEnumMeta.__prepare__cs�|j|�\�}|j��|�\}}}�fdd��jD�}x�jD]
}	�|	=q>W�jdd�}
t|�dh@}|r~tdjdj|����d�kr�d�d<t�j	|||��}g|_
t�|_�|_
d	d
�|j�D�}
i|_d�k�r�tk	�rd}t�fdd�|D���st|��x6�jD�]*}||}t|t��s0|f}n|}�tk�rD|f}|�sf||�}t|d��s�||_n6||f|��}t|d��s��tk�r�||_n
�|�|_|j}||_||_|j|�x8|jj�D]\}	}|j|jk�r�|}P�q�W|j
j|�||
k�rt|||�||j|<y||j|<Wntk
�r6YnX�qWxPdD]H}	t||	�}t�|	d�}t||	d�}|dk	�rD||k�rDt||	|��qDWtdk	�r�|�r�||_ tj	|_	|
dk	�r�t|
t!��r�|
j"dd�j#�}
|
|j
k�r�td��|S)Ncsi|]}�||�qSrr)�.0�k)�	classdictrr�
<dictcomp>�sz$EnumMeta.__new__.<locals>.<dictcomp>r6�mrozInvalid enum member name: {0}�,r-zAn enumeration.cSs.h|]&}|jj�D]\}}t|t�r|�qqSr)�__dict__�itemsr>r)rK�crL�vrrr�	<setcomp>�sz#EnumMeta.__new__.<locals>.<setcomp>r'�__getnewargs_ex__�__getnewargs__�
__reduce__c3s|]}|�jkVqdS)N)rQ)rK�m)rHrr�	<genexpr>�sz#EnumMeta.__new__.<locals>.<genexpr>�_value_�__repr__�__str__�
__format__� z#member order does not match _order_)rVrWr'rX)r\r]r^r')$rC�
_find_new_r3�pop�setr<�format�joinr1�__new__�_member_names_r�_member_map_�
_member_type_rO�_value2member_map_�object�anyr*r>�tuplerr[�_name_�__objclass__r2rRr?r=r#rDr�__new_member__�str�replace�split)rEr)rFrMrIre�save_new�use_args�enum_membersrr6�
invalid_names�
enum_class�dynamic_attributes�methods�member_namer/�args�enum_member�canonical_member�class_method�
obj_method�enum_method)r5)rMrHrre|s�












zEnumMeta.__new__cCsdS)z6
        classes/types should always be True.
        Tr)r$rrr�__bool__szEnumMeta.__bool__Nr )�module�qualname�type�startcCs*|dkr|j||�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�)re�_create_)r)r/�namesr�r�r�r�rrr�__call__szEnumMeta.__call__cCst||�o|j|jkS)N)r>rmrg)r)�memberrrr�__contains__)szEnumMeta.__contains__cs(||jkrtd|j��t�j|�dS)Nz%s: cannot delete Enum member.)rg�AttributeErrorr+r1�__delattr__)r)�attr)r5rrr�,s
zEnumMeta.__delattr__cCsddddg|jS)Nr5r-�__members__r()rf)r$rrr�__dir__4s
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�rg�KeyError)r)rrrr�__getattr__8s	
zEnumMeta.__getattr__cCs
|j|S)N)rg)r)rrrr�__getitem__HszEnumMeta.__getitem__cs�fdd��jD�S)Nc3s|]}�j|VqdS)N)rg)rKr)r)rrrZLsz$EnumMeta.__iter__.<locals>.<genexpr>)rf)r)r)r)r�__iter__KszEnumMeta.__iter__cCs
t|j�S)N)rrf)r)rrr�__len__NszEnumMeta.__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.

        )rrg)r)rrrr�QszEnumMeta.__members__cCs
d|jS)Nz	<enum %r>)r+)r)rrrr\[szEnumMeta.__repr__cs�fdd�t�j�D�S)Nc3s|]}�j|VqdS)N)rg)rKr)r)rrrZ_sz(EnumMeta.__reversed__.<locals>.<genexpr>)�reversedrf)r)r)r)r�__reversed__^szEnumMeta.__reversed__cs0|jjdi�}||krtd��t�j||�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.

        rgzCannot reassign members.N)rQ�getr�r1�__setattr__)r)rr/�
member_map)r5rrr�aszEnumMeta.__setattr__cCs�|j}|dkr|fn||f}|j|�\}	}
|j||�}t|t�rP|jdd�j�}t|ttf�r�|r�t|dt�r�|g}}g}
xDt	|�D]8\}}|
j
||||
dd��}|
j|�|j||f�q�Wx6|D].}t|t�r�|||}}n|\}}|||<q�W|j||||�}|dk�rTyt
jd�jd}Wn(ttfk
�rR}zWYdd}~XnX|dk�rht|�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.

        NrPr_rrr+)r5rCrJr>rprqrrrl�list�	enumerater8r?re�sys�	_getframe�	f_globalsr�r<r*r(r,)r)�
class_namer�r�r�r�r�rErFrrIrM�original_names�last_values�countrr/�itemrz�member_valuerw�excrrrr�ns<
 







zEnumMeta._create_cCs�|sttfSd}}x,|D]$}|tk	rt|t�r|jrtd��qWt|t�sTtd��t|dt�st|d}|d}n8x6|djD](}t|t�r�|dkr�|}q�|dkr�|}q�W||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__

        NzCannot extend enumerationszHnew enumerations must be created as `ClassName([mixin_type,] enum_type)`rr r!)rjr�
issubclassrfr#�__mro__)rFrHrI�baserrrrC�s(




zEnumMeta._get_mixins_c	Cs�|jdd�}|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__

        reNroFT)rore)r�rDrerjr)	rMrHrIrers�method�possible�targetrtrrrr`�s(


zEnumMeta._find_new_)N)r+r(r,r-�classmethodrJrer�r�r�r�r�r�r�r�r��propertyr�r\r�r�r��staticmethodrCr`rBrr)r5rrps(



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.

    cCsjt|�|kr|Sy||jkr&|j|SWn6tk
r^x |jj�D]}|j|krD|SqDWYnX|j|�S)N)r�rir#rg�valuesr[r9)r)r/r�rrrres

zEnum.__new__cCs8x2t|�D]"}y|dStk
r*Yq
Xq
W|SdS)Nr )r�r#)rr�r�r��
last_valuerrrr8s
zEnum._generate_next_value_cCstd||jf��dS)Nz%r is not a valid %s)r<r+)r)r/rrrr9"szEnum._missing_cCsd|jj|j|jfS)Nz<%s.%s: %r>)r5r+rmr[)r$rrrr\&sz
Enum.__repr__cCsd|jj|jfS)Nz%s.%s)r5r+rm)r$rrrr]*szEnum.__str__cs&�fdd��jj�D�}dddg|S)Ncs2g|]*}|jD]}|ddkr|�jkr|�qqS)rr)rQrg)rKr)rY)r$rr�
<listcomp>/s
z Enum.__dir__.<locals>.<listcomp>r5r-r()r5rO)r$�added_behaviorr)r$rr�-s
zEnum.__dir__cCs0|jtkrt}t|�}n|j}|j}|j||�S)N)rhrjrpr[r^)r$�format_specr)�valrrrr^6s

zEnum.__format__cCs
t|j�S)N)�hashrm)r$rrr�__hash__Esz
Enum.__hash__cCs|j|jffS)N)r5r[)r$r%rrrr'HszEnum.__reduce_ex__cCs|jS)zThe name of the Enum member.)rm)r$rrrrRsz	Enum.namecCs|jS)zThe value of the Enum member.)r[)r$rrrr/Wsz
Enum.valueNc
s�ttj|�}�rt���n|���fdd��j�D�}y|jdd�d�Wn$tk
rp|jdd�d�YnX||||d�}t|_|j|j	�|||<|S)z[
        Create a new Enum subclass that replaces a collection of global constants
        cs g|]}�|�r|�|f�qSrr)rKr)�filter�sourcerrr�qsz!Enum._convert.<locals>.<listcomp>cSs|d|dfS)Nr rr)�trrr�<lambda>vszEnum._convert.<locals>.<lambda>)rAcSs|dS)Nrr)r�rrrr�ys)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-rer8r�r9r\r]r�r^r�r'rrr/r�rrrrr�s		
)�	metaclassc@seZdZdZdS)r	z.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)r
zSupport 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 initital start value or None
        count: the number of existing members
        last_value: the last value assigned or None
        Nr zInvalid Flag value: %rr)r��	_high_bit�	Exceptionr#)rr�r�r�r��high_bitrrrr8�s	zFlag._generate_next_value_cCs.|}|dkr|}|j|�}|dkr*|}|S)Nr)r7)r)r/�original_value�possible_memberrrrr9�s
zFlag._missing_cCsb|jj|d�}|dkr^t||�\}}|r:td||jf��tj|�}d|_||_|jj	||�}|S)zL
        Create a composite member iff value contains only members.
        Nz%r is not a valid %s)
rir��
_decomposer<r+rjrermr[�
setdefault)r)r/�
pseudo_memberr�extra_flagsrrrr7�s
zFlag._create_pseudo_member_cCs"t||j�stS|j|j@|jkS)N)r>r5�NotImplementedr[)r$�otherrrrr��szFlag.__contains__cCsV|j}|jdk	r$d|j|j|jfSt||j�\}}d|jdjdd�|D��|jfS)Nz<%s.%s: %r>�|cSsg|]}t|jp|j��qSr)rprmr[)rKrYrrrr��sz!Flag.__repr__.<locals>.<listcomp>)r5rmr+r[r�rd)r$r)r��	uncoveredrrrr\�s
z
Flag.__repr__cCs�|j}|jdk	r d|j|jfSt||j�\}}t|�dkr^|djdkr^d|j|djfSd|jdjdd�|D��fSdS)Nz%s.%sr rz%s.%rr�cSsg|]}t|jp|j��qSr)rprmr[)rKrYrrrr��sz Flag.__str__.<locals>.<listcomp>)r5rmr+r�r[rrd)r$r)r�r�rrrr]�s
zFlag.__str__cCs
t|j�S)N)�boolr[)r$rrrr��sz
Flag.__bool__cCs"t||j�stS|j|j|jB�S)N)r>r5r�r[)r$r�rrr�__or__�szFlag.__or__cCs"t||j�stS|j|j|j@�S)N)r>r5r�r[)r$r�rrr�__and__�szFlag.__and__cCs"t||j�stS|j|j|jA�S)N)r>r5r�r[)r$r�rrr�__xor__�szFlag.__xor__csDt�j�j�\�}��fdd��jD�}tt|�jd��}�j|�S)Ncs&g|]}|�kr|j�j@r|�qSr)r[)rKrY)r�r$rrr��sz#Flag.__invert__.<locals>.<listcomp>r)r�r5r[r�_or_)r$r��inverted_members�invertedr)r�r$r�
__invert__�szFlag.__invert__N)r+r(r,r-r8r�r9r7r�r\r]r�r�r�r�r�rrrrr
�s

c@sTeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	eZ
eZe	Zdd
�Z
dS)rzSupport for integer-based FlagscCs*t|t�std||jf��|j|�}|S)Nz%r is not a valid %s)r>�intr<r+r7)r)r/�
new_memberrrrr9�s

zIntFlag._missing_cCs�|jj|d�}|dkr�|g}t||�\}}xL|rvt|�}d|}||jkr\||kr\|j|�||krld}q,||N}q,Wx6t|�D]*}tj||�}d|_||_	|jj
||�}q�W|S)Nrr)rir�r�r�r?r�r�rermr[r�)r)r/r��need_to_createrr��bit�
flag_valuerrrr7�s&


zIntFlag._create_pseudo_member_cCs0t||jtf�stS|j|j|j|�jB�}|S)N)r>r5r�r�r[)r$r��resultrrrr�szIntFlag.__or__cCs,t||jtf�stS|j|j|j|�j@�S)N)r>r5r�r�r[)r$r�rrrr�#szIntFlag.__and__cCs,t||jtf�stS|j|j|j|�jA�S)N)r>r5r�r�r[)r$r�rrrr�(szIntFlag.__xor__cCs|j|j�}|S)N)r5r[)r$r�rrrr�1szIntFlag.__invert__N)r+r(r,r-r�r9r7r�r�r��__ror__�__rand__�__rxor__r�rrrrr�scCs|j�dS)z@returns index of highest bit, or -1 if value is zero or negativer )�
bit_length)r/rrrr�6sr�cCsbg}x0|jj�D]"\}}||jkr|j||jf�qW|r^djdd�|D��}td||f��|S)z?Class decorator for enumerations ensuring unique member values.z, cSsg|]\}}d||f�qS)z%s -> %sr)rK�aliasrrrrr�Bszunique.<locals>.<listcomp>z duplicate values found in %r: %s)r�rRrr?rdr<)�enumeration�
duplicatesrr��
alias_detailsrrrr
:s
cCs�|}|dk}|r*dd�t|jj��D�}ndd�t|jj��D�}g}x4|D],\}}|rL||@|krL|j|�||M}qLW|r�||jkr�|j|j|�|jdd�dd�t|�d	kr�|dj|kr�|jd�||fS)
z#Extract all members from the value.rcSs"g|]\}}|jdk	r||f�qS)N)r)rKrTrYrrrr�Rsz_decompose.<locals>.<listcomp>cSs*g|]"\}}|jdk	st|�r||f�qS)N)r�
_power_of_two)rKrTrYrrrr�YscSs|jS)N)r[)rYrrrr�dsz_decompose.<locals>.<lambda>T)rA�reverser )r�rirRr?r�rr/ra)�flagr/�not_covered�negative�flags_to_checkr�r�r�rrrr�Gs$

r�cCs|dkrdS|dt|�kS)Nr Fr)r�)r/rrrr�jsr�)#r��typesrr�	functoolsr�operatorrr��_collectionsr�ImportError�collections�__all__rrr"r*rjr.r�dictr0rr�rr�r	r�r
rr�r
r�r�rrrr�<module>s@3mA
#

?>