Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/enum.cpython-35.pyc



��Yf�V�@s�ddlZddlmZddlmZmZdddgZdd�Zd	d
�Zdd�Z	d
d�Z
Gdd�de�ZdZ
Gdd�de�ZGdd�dde�Z
Gdd�dee
�Zdd�Zdd�ZdS)�N)�OrderedDict)�MappingProxyType�DynamicClassAttribute�Enum�IntEnum�uniquecCs+t|d�p*t|d�p*t|d�S)z5Returns True if obj is a descriptor, False otherwise.�__get__�__set__�
__delete__)�hasattr)�obj�r
�)/opt/alt/python35/lib64/python3.5/enum.py�_is_descriptorsrcCsl|dd�|dd�ko+dknok|dd�dkok|dd	�dkokt|�dkS)
z3Returns True if a __dunder__ name, False otherwise.N��__��_�������r)�len)�namer
r
r�
_is_dunders0rcCs`|d|dkodkno_|dd�dko_|dd�dko_t|�dkS)z1Returns True if a _sunder_ name, False otherwise.r�rr���rr)r)rr
r
r�
_is_sunders$rcCs"dd�}||_d|_dS)z"Make the given class un-picklable.cSstd|��dS)Nz%r cannot be pickled)�	TypeError)�self�protor
r
r�_break_on_call_reduce"sz6_make_class_unpicklable.<locals>._break_on_call_reducez	<unknown>N)�
__reduce_ex__�
__module__)�clsr r
r
r�_make_class_unpicklable s	r$cs:eZdZdZ�fdd�Z�fdd�Z�S)�	_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|_dS)N)�super�__init__�
_member_names)r)�	__class__r
rr'/s
z_EnumDict.__init__cs�t|�rtd��nmt|�r*n^||jkrLtd|��n<t|�s�||krxtd||��|jj|�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.

        z(_names_ are reserved for future Enum usezAttempted to reuse key: %rzKey already defined as: %rN)	r�
ValueErrorrr(rr�appendr&�__setitem__)r�key�value)r)r
rr,3s	z_EnumDict.__setitem__)�__name__r"�__qualname__�__doc__r'r,r
r
)r)rr%(sr%csNeZdZdZedd��Z�fdd�Zdd�Zdd	dd
ddddd
dd�Zdd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��Zd d!�Zd"d#�Z�fd$d%�Zdd	dd
ddddd
d&d'�Zed(d)��Zed*d+��Z�S),�EnumMetazMetaclass for EnumcCst�S)N)r%)�metaclsr#�basesr
r
r�__prepare__TszEnumMeta.__prepare__cs^|j|�\�}|j��|�\}}}�fdd��jD�}x�jD]
}	�|	=qYWt|�dh@}
|
r�tdjdj|
����d�kr�d�d<t�j|||��}g|_	t
�|_�|_dd	�|j
�D�}i|_d
�krY�tk	rYd}
t�fdd�|
D��sYt|�xk�jD]`}||}t|t�s�|f}n|}�tkr�|f}|s�||�}t|d�s||_n-|||�}t|d�s�|�|_|j}||_||_|j|�xF|jj�D]%\}	}|j|jkr;|}Pq;W|j	j|�||kr�t|||�||j|<y||j|<Wqctk
r�YqcXqcWxidD]a}	t||	�}t�|	d�}t||	d�}|dk	r�||kr�t||	|�q�Wtdk	rZ|rN||_tj|_|S)Ncsi|]}�||�qSr
r
)�.0�k)�	classdictr
r�
<dictcomp>cs	z$EnumMeta.__new__.<locals>.<dictcomp>�mrozInvalid enum member name: {0}�,r1zAn enumeration.cSs&h|]}|jD]}|�qqSr
)�__dict__)r6�b�ar
r
r�	<setcomp>ys	z#EnumMeta.__new__.<locals>.<setcomp>r!�__getnewargs_ex__�__getnewargs__�
__reduce__c3s|]}|�jkVqdS)N)r<)r6�m)�member_typer
r�	<genexpr>�sz#EnumMeta.__new__.<locals>.<genexpr>�_value_�__repr__�__str__�
__format__)r@rAr!rB)rGrHrIr!) �_get_mixins_�
_find_new_r(�setr*�format�joinr&�__new__�_member_names_r�_member_map_�
_member_type_r:�_value2member_map_�object�anyr$�
isinstance�tuplerrF�_name_�__objclass__r'�itemsr+�setattrr�getattrr�__new_member__)r3r#r4r8�
first_enumrO�save_new�use_args�membersrZ
invalid_names�
enum_classZbase_attributesZmethods�member_namer.�argsZenum_memberZcanonical_memberZclass_methodZ
obj_methodZenum_method)r))r8rDrrOXs�	
			

				


	
	zEnumMeta.__new__cCsdS)z6
        classes/types should always be True.
        Tr
)rr
r
r�__bool__�szEnumMeta.__bool__N�module�qualname�type�startrcCsD|dkr|j||�S|j||d|d|d|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.

        Nrfrgrhri)rO�_create_)r#r.�namesrfrgrhrir
r
r�__call__�szEnumMeta.__call__cCst||�o|j|jkS)N)rVrXrQ)r#�memberr
r
r�__contains__�szEnumMeta.__contains__cs6||jkr"td|j��t�j|�dS)Nz%s: cannot delete Enum member.)rQ�AttributeErrorr/r&�__delattr__)r#�attr)r)r
rrp�szEnumMeta.__delattr__cCsddddg|jS)Nr)r1�__members__r")rP)rr
r
r�__dir__szEnumMeta.__dir__cCsOt|�rt|��y|j|SWn!tk
rJt|�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)rrorQ�KeyError)r#rr
r
r�__getattr__s	
zEnumMeta.__getattr__cCs|j|S)N)rQ)r#rr
r
r�__getitem__szEnumMeta.__getitem__cs�fdd��jD�S)Nc3s|]}�j|VqdS)N)rQ)r6r)r#r
rrEsz$EnumMeta.__iter__.<locals>.<genexpr>)rP)r#r
)r#r�__iter__szEnumMeta.__iter__cCs
t|j�S)N)rrP)r#r
r
r�__len__szEnumMeta.__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.

        )rrQ)r#r
r
rrrszEnumMeta.__members__cCsd|jS)Nz	<enum %r>)r/)r#r
r
rrG'szEnumMeta.__repr__cs �fdd�t�j�D�S)Nc3s|]}�j|VqdS)N)rQ)r6r)r#r
rrE+sz(EnumMeta.__reversed__.<locals>.<genexpr>)�reversedrP)r#r
)r#r�__reversed__*szEnumMeta.__reversed__csD|jjdi�}||kr-td��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.

        rQzCannot reassign members.N)r<�getror&�__setattr__)r#rr.Z
member_map)r)r
rr|-szEnumMeta.__setattr__cCs�|j}|dkr|fn	||f}|j||�}	t|t�rc|jdd�j�}t|ttf�r�t|dt�r�dd�t||�D�}xG|D]?}
t|
t�r�|
||
}}n|
\}}||	|<q�W|j	||||	�}
|dkr]yt
jd�jd}Wn+t
tfk
r\}zWYdd}~XnX|dkrvt|
�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;� rcSs"g|]\}}||f�qSr
r
)r6�i�er
r
r�
<listcomp>Ns	z%EnumMeta._create_.<locals>.<listcomp>rr/)r)r5rV�str�replace�splitrW�list�	enumeraterO�sys�	_getframe�	f_globalsror*r$r"r0)r#Z
class_namerkrfrgrhrir3r4r8�itemrcZmember_valuerb�excr
r
rrj:s0	!(

		zEnumMeta._create_cCs�|sttfSd}}x>|D]6}|tk	r!t|t�r!|jr!td��q!Wt|t�svtd��t|dt�s�|d}|d}nNxK|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)`rrr)rTr�
issubclassrPr�__mro__)r4rDr^�baser
r
rrJis(


	

	
zEnumMeta._get_mixins_c	Cs�|jdd�}|dk	}|dkr�xudD]d}xN||fD]@}t||d�}|ddjtjtjhkrD|}PqDW|dk	r1Pq1Wtj}|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__

        rONr]FT)r]rO)r{r\rOrTr)	r8rDr^rOr_�methodZpossible�targetr`r
r
rrK�s(
		zEnumMeta._find_new_)r/r"r0r1�classmethodr5rOrerlrnrprsrurvrwrx�propertyrrrGrzr|rj�staticmethodrJrKr
r
)r)rr2Rs&y'

'/-r2c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
edd��Zedd��Z
eddd��ZdS)rzRGeneric enumeration.

    Derive from this class to define new enumerations.

    cCs�t|�|kr|Sy||jkr3|j|SWn?tk
rux*|jj�D]}|j|krT|SqTWYnXtd||jf��dS)Nz%r is not a valid %s)rhrSrrQ�valuesrFr*r/)r#r.rmr
r
rrO�s

zEnum.__new__cCsd|jj|j|jfS)Nz<%s.%s: %r>)r)r/rXrF)rr
r
rrG�sz
Enum.__repr__cCsd|jj|jfS)Nz%s.%s)r)r/rX)rr
r
rrH�szEnum.__str__cs3�fdd��jj�D�}dddg|S)NcsEg|];}|jD]+}|ddkr|�jkr|�qqS)rr)r<rQ)r6r#rC)rr
rr��s	
z Enum.__dir__.<locals>.<listcomp>r)r1r")r)r:)rZadded_behaviorr
)rrrs�szEnum.__dir__cCsF|jtkr$t}t|�}n|j}|j}|j||�S)N)rRrTr�rFrI)rZformat_specr#�valr
r
rrI�s		zEnum.__format__cCs
t|j�S)N)�hashrX)rr
r
r�__hash__�sz
Enum.__hash__cCs|j|jffS)N)r)rF)rrr
r
rr!szEnum.__reduce_ex__cCs|jS)zThe name of the Enum member.)rX)rr
r
rr
sz	Enum.namecCs|jS)zThe value of the Enum member.)rF)rr
r
rr.sz
Enum.valueNcs�ttj|�}|r(t|�}n|}�fdd�|j�D�}|||d|�}t|_|j|j�|||<|S)z[
        Create a new Enum subclass that replaces a collection of global constants
        cs+i|]!\}}�|�r||�qSr
r
)r6rr.)�filterr
rr9#s		z!Enum._convert.<locals>.<dictcomp>rf)�varsr��modulesrZ�_reduce_ex_by_namer!�updaterr)r#rrfr��source�module_globalsrar
)r�r�_converts
	
z
Enum._convert)r/r"r0r1rOrGrHrsrIr�r!rrr.r�r�r
r
r
rr�s	
�	metaclassc@seZdZdZdS)rz.Enum where members are also (and must be) intsN)r/r"r0r1r
r
r
rr,scCs|jS)N)r)rrr
r
rr�0sr�cCs�g}xB|jj�D]1\}}||jkr|j||jf�qW|r�djdd�|D��}td||f��|S)z?Class decorator for enumerations ensuring unique member values.z, cSs&g|]\}}d||f�qS)z%s -> %sr
)r6�aliasrr
r
rr�;s	zunique.<locals>.<listcomp>z duplicate values found in %r: %s)rrrZrr+rNr*)ZenumerationZ
duplicatesrrmZ
alias_detailsr
r
rr3s)r��collectionsr�typesrr�__all__rrrr$�dictr%rrhr2�intrr�rr
r
r
r�<module>s'�tg

Hacked By AnonymousFox1.0, Coded By AnonymousFox