
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \Fƒ  ã               @   s>  d dl Z d dlmZmZ d dlmZ d dlmZ yd dl	m
Z
 W n  ek
r`   d dlm
Z
 Y nX dddd	d
ddgZdd„ Zdd„ Zdd„ Zdd„ Zeƒ ZG dd„ dƒZG dd„ deƒZdZG dd„ deƒZG dd„ ded�ZG dd„ deeƒZdd„ ZG dd	„ d	eƒZG dd
„ d
eeƒZd d!„ Zd"d„ Z d#d$„ Z!d%d&„ Z"dS )'é    N)ÚMappingProxyTypeÚDynamicClassAttribute)Úreduce)Úor_)ÚOrderedDictÚEnumMetaÚEnumÚIntEnumÚFlagÚIntFlagÚautoÚuniquec             C   s   t | dƒpt | dƒpt | dƒS )z5Returns True if obj is a descriptor, False otherwise.Ú__get__Ú__set__Ú
__delete__)Úhasattr)Úobj© r   ú/usr/lib64/python3.6/enum.pyÚ_is_descriptor   s    

r   c             C   sT   | dd… | dd…   ko"dkn  oR| dd… dkoR| dd	… dkoRt | ƒdkS )
z3Returns True if a __dunder__ name, False otherwise.Né   Ú__é   Ú_é   éþÿÿÿéýÿÿÿr   )Úlen)Únamer   r   r   Ú
_is_dunder   s    (r   c             C   sL   | d | d   kodkn  oJ| dd… dkoJ| dd… dkoJt | ƒdkS )z1Returns True if a _sunder_ name, False otherwise.r   é   r   r   éÿÿÿÿr   r!   )r   )r   r   r   r   Ú
_is_sunder$   s     r"   c             C   s   dd„ }|| _ d| _dS )z"Make the given class un-picklable.c             S   s   t d|  ƒ‚d S )Nz%r cannot be pickled)Ú	TypeError)ÚselfÚprotor   r   r   Ú_break_on_call_reduce-   s    z6_make_class_unpicklable.<locals>._break_on_call_reducez	<unknown>N)Ú__reduce_ex__Ú
__module__)Úclsr&   r   r   r   Ú_make_class_unpicklable+   s    r*   c               @   s   e Zd ZdZeZdS )r   zP
    Instances are replaced with an appropriate value in Enum class suites.
    N)Ú__name__r(   Ú__qualname__Ú__doc__Ú
_auto_nullÚvaluer   r   r   r   r   3   s   c                   s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  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.

    c                s   t ƒ jƒ  g | _g | _d S )N)ÚsuperÚ__init__Ú_member_namesÚ_last_values)r$   )Ú	__class__r   r   r2   A   s    
z_EnumDict.__init__c                sæ   t |ƒr.|dkrtdƒ‚|dkrÔt| d|ƒ n¦t|ƒrD|dkrÔd}n�|| jkr\td| ƒ‚nxt|ƒsÔ|| kr€td	|| | f ƒ‚t|tƒr¼|j	t
kr¶| j|d
t| jƒ| jdd… ƒ|_	|j	}| jj|ƒ | jj|ƒ tƒ j||ƒ dS )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__zAttempted to reuse key: %rz%r already defined as: %rr    N)r6   r7   r8   r9   )r"   Ú
ValueErrorÚsetattrr   r3   r#   r   Ú
isinstancer   r/   r.   r:   r   r4   Úappendr1   Ú__setitem__)r$   Úkeyr/   )r5   r   r   r@   F   s,    	 


"z_EnumDict.__setitem__)r+   r(   r,   r-   r2   r@   Ú__classcell__r   r   )r5   r   r0   :   s   r0   c                   sÚ   e Zd ZdZedd„ ƒZ‡ fdd„Zdd„ Zd)dddd	d
œdd„Zdd„ Z	‡ fdd„Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZdd„ Zdd „ Z‡ fd!d"„Zdddd	d
œd#d$„Zed%d&„ ƒZed'd(„ ƒZ‡  ZS )*r   zMetaclass for Enumc             C   s0   t ƒ }| j|ƒ\}}|d k	r,t|dd ƒ|d< |S )Nr8   )r0   Ú_get_mixins_Úgetattr)Úmetaclsr)   ÚbasesÚ	enum_dictÚmember_typeÚ
first_enumr   r   r   Ú__prepare__r   s
    zEnumMeta.__prepare__c                sì  | j |ƒ\‰}| jˆ ˆ|ƒ\}}}‡ fdd„ˆ jD ƒ}xˆ jD ]
}	ˆ |	= q>W ˆ jdd ƒ}
t|ƒdh@ }|r~tdjdj|ƒƒƒ‚dˆ krŽdˆ d< tƒ j	| ||ˆ ƒ}g |_
tƒ |_ˆ|_d	d
„ |jƒ D ƒ}i |_dˆ k�rˆtk	�rd}t‡fdd„|D ƒƒ�st|ƒ �x6ˆ jD �]*}|| }t|tƒ�s0|f}n|}ˆtk�rD|f}|�sf||ƒ}t|dƒ�sœ||_n6||f|žŽ }t|dƒ�sœˆtk�r’||_n
ˆ|Ž |_|j}||_||_|j|Ž  x8|jjƒ D ]\}	}|j|jk�rÄ|}P �qÄW |j
j|ƒ ||k�rt|||ƒ ||j|< y||j|< W n tk
�r6   Y nX �qW xPdD ]H}	t||	ƒ}tˆ|	d ƒ}t||	d ƒ}|d k	�rD||k�rDt||	|ƒ �qDW td k	�r®|�r¦||_ tj	|_	|
d k	�rèt|
t!ƒ�rÔ|
j"ddƒj#ƒ }
|
|j
k�rètdƒ‚|S )Nc                s   i | ]}ˆ | |“qS r   r   )Ú.0Úk)Ú	classdictr   r   ú
<dictcomp>‡   s    z$EnumMeta.__new__.<locals>.<dictcomp>r6   ÚmrozInvalid enum member name: {0}ú,r-   zAn enumeration.c             S   s.   h | ]&}|j jƒ D ]\}}t|tƒr|’qqS r   )Ú__dict__Úitemsr>   r   )rK   ÚcrL   Úvr   r   r   ú	<setcomp>    s    z#EnumMeta.__new__.<locals>.<setcomp>r'   Ú__getnewargs_ex__Ú__getnewargs__Ú
__reduce__c             3   s   | ]}|ˆ j kV  qd S )N)rQ   )rK   Úm)rH   r   r   ú	<genexpr>µ   s    z#EnumMeta.__new__.<locals>.<genexpr>Ú_value_Ú__repr__Ú__str__Ú
__format__ú z#member order does not match _order_)rV   rW   r'   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>   Útupler   r[   Ú_name_Ú__objclass__r2   rR   r?   r=   r#   rD   r   Ú__new_member__ÚstrÚreplaceÚsplit)rE   r)   rF   rM   rI   re   Úsave_newÚuse_argsÚenum_membersr   r6   Úinvalid_namesÚ
enum_classÚdynamic_attributesÚmethodsÚmember_namer/   ÚargsÚenum_memberÚcanonical_memberÚclass_methodÚ
obj_methodÚenum_method)r5   )rM   rH   r   re   |   s’    


 









zEnumMeta.__new__c             C   s   dS )z6
        classes/types should always be True.
        Tr   )r$   r   r   r   Ú__bool__  s    zEnumMeta.__bool__Nr    )ÚmoduleÚqualnameÚtypeÚstartc            C   s*   |dkr| j | |ƒS | j||||||d�S )a  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')).

        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…   r   r   r   Ú__call__  s    zEnumMeta.__call__c             C   s   t || ƒo|j| jkS )N)r>   rm   rg   )r)   Úmemberr   r   r   Ú__contains__)  s    zEnumMeta.__contains__c                s(   || j krtd| j ƒ‚tƒ j|ƒ d S )Nz%s: cannot delete Enum member.)rg   ÚAttributeErrorr+   r1   Ú__delattr__)r)   Úattr)r5   r   r   rŒ   ,  s    
zEnumMeta.__delattr__c             C   s   ddddg| j  S )Nr5   r-   Ú__members__r(   )rf   )r$   r   r   r   Ú__dir__4  s    
zEnumMeta.__dir__c             C   s>   t |ƒrt|ƒ‚y
| j| S  tk
r8   t|ƒd‚Y nX dS )a5  Return 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)r   r‹   rg   ÚKeyError)r)   r   r   r   r   Ú__getattr__8  s    	
zEnumMeta.__getattr__c             C   s
   | j | S )N)rg   )r)   r   r   r   r   Ú__getitem__H  s    zEnumMeta.__getitem__c                s   ‡ fdd„ˆ j D ƒS )Nc             3   s   | ]}ˆ j | V  qd S )N)rg   )rK   r   )r)   r   r   rZ   L  s    z$EnumMeta.__iter__.<locals>.<genexpr>)rf   )r)   r   )r)   r   Ú__iter__K  s    zEnumMeta.__iter__c             C   s
   t | jƒS )N)r   rf   )r)   r   r   r   Ú__len__N  s    zEnumMeta.__len__c             C   s
   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   rg   )r)   r   r   r   rŽ   Q  s    zEnumMeta.__members__c             C   s
   d| j  S )Nz	<enum %r>)r+   )r)   r   r   r   r\   [  s    zEnumMeta.__repr__c                s   ‡ fdd„t ˆ jƒD ƒS )Nc             3   s   | ]}ˆ j | V  qd S )N)rg   )rK   r   )r)   r   r   rZ   _  s    z(EnumMeta.__reversed__.<locals>.<genexpr>)Úreversedrf   )r)   r   )r)   r   Ú__reversed__^  s    zEnumMeta.__reversed__c                s0   | j jdi ƒ}||krtdƒ‚tƒ j||ƒ dS )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.

        rg   zCannot reassign members.N)rQ   Úgetr‹   r1   Ú__setattr__)r)   r   r/   Ú
member_map)r5   r   r   r˜   a  s    zEnumMeta.__setattr__c            C   s‚  | j }|dkr| fn|| f}| j|ƒ\}	}
|j||ƒ}t|tƒrP|jddƒjƒ }t|ttfƒrÄ|rÄt|d tƒrÄ|g  }}g }xDt	|ƒD ]8\}}|
j
||||dd… ƒ}|j|ƒ |j||fƒ qˆW x6|D ].}t|tƒrè|||  }}n|\}}|||< qÊW |j||||ƒ}|dk�rTytjdƒjd }W n( ttfk
�rR } zW Y dd}~X nX |dk�rht|ƒ n||_|dk	�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.

        NrP   r_   r   r   r+   )r5   rC   rJ   r>   rp   rq   rr   rl   ÚlistÚ	enumerater8   r?   re   ÚsysÚ	_getframeÚ	f_globalsr‹   r<   r*   r(   r,   )r)   Ú
class_namer‡   r‚   rƒ   r„   r…   rE   rF   r   rI   rM   Úoriginal_namesÚlast_valuesÚcountr   r/   Úitemrz   Úmember_valuerw   Úexcr   r   r   r†   n  s<    
 







zEnumMeta._create_c             C   s´   | st tfS d }}x,| D ]$}|tk	rt|tƒr|jrtdƒ‚qW t|tƒsTtdƒ‚t| d tƒst| d }| d }n8x6| d jD ](}t|tƒrœ|dkr¨|}q€|dkr€|}q€W ||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__

        NzCannot extend enumerationszHnew enumerations must be created as `ClassName([mixin_type,] enum_type)`r   r    r!   )rj   r   Ú
issubclassrf   r#   Ú__mro__)rF   rH   rI   Úbaser   r   r   rC   £  s(    




zEnumMeta._get_mixins_c       	      C   s’   | j ddƒ}|dk	}|dkrtxVdD ]H}x8||fD ],}t||dƒ}|ddjtjtjhkr0|}P q0W |dk	r"P q"W tj}|tjk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__

        re   Nro   FT)ro   re   )r—   rD   re   rj   r   )	rM   rH   rI   re   rs   ÚmethodÚpossibleÚtargetrt   r   r   r   r`   Ð  s(    


zEnumMeta._find_new_)N)r+   r(   r,   r-   ÚclassmethodrJ   re   r�   rˆ   rŠ   rŒ   r�   r‘   r’   r“   r”   ÚpropertyrŽ   r\   r–   r˜   r†   ÚstaticmethodrC   r`   rB   r   r   )r5   r   r   p   s(   
 

5-c               @   s‚   e Zd ZdZdd„ Zdd„ Zedd„ ƒZdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zedd„ ƒZedd„ ƒZeddd„ƒZdS )r   zRGeneric enumeration.

    Derive from this class to define new enumerations.

    c             C   sj   t |ƒ| kr|S y|| jkr&| j| S W n6 tk
r^   x | jjƒ D ]}|j|krD|S qDW Y nX | j|ƒS )N)r„   ri   r#   rg   Úvaluesr[   r9   )r)   r/   r‰   r   r   r   re     s    

zEnum.__new__c             C   s8   x2t |ƒD ]"}y|d S  tk
r*   Y q
X q
W |S d S )Nr    )r•   r#   )r   r…   r¢   r¡   Ú
last_valuer   r   r   r8     s    
zEnum._generate_next_value_c             C   s   t d|| jf ƒ‚d S )Nz%r is not a valid %s)r<   r+   )r)   r/   r   r   r   r9   "  s    zEnum._missing_c             C   s   d| j j| j| jf S )Nz<%s.%s: %r>)r5   r+   rm   r[   )r$   r   r   r   r\   &  s    zEnum.__repr__c             C   s   d| j j| jf S )Nz%s.%s)r5   r+   rm   )r$   r   r   r   r]   *  s    zEnum.__str__c                s&   ‡ fdd„ˆ j jƒ D ƒ}dddg| S )Nc                s2   g | ]*}|j D ]}|d  dkr|ˆ jkr|‘qqS )r   r   )rQ   rg   )rK   r)   rY   )r$   r   r   ú
<listcomp>/  s   
z Enum.__dir__.<locals>.<listcomp>r5   r-   r(   )r5   rO   )r$   Úadded_behaviorr   )r$   r   r�   -  s    
zEnum.__dir__c             C   s0   | j tkrt}t| ƒ}n| j }| j}|j||ƒS )N)rh   rj   rp   r[   r^   )r$   Úformat_specr)   Úvalr   r   r   r^   6  s    

zEnum.__format__c             C   s
   t | jƒS )N)Úhashrm   )r$   r   r   r   Ú__hash__E  s    zEnum.__hash__c             C   s   | j | jffS )N)r5   r[   )r$   r%   r   r   r   r'   H  s    zEnum.__reduce_ex__c             C   s   | j S )zThe name of the Enum member.)rm   )r$   r   r   r   r   R  s    z	Enum.namec             C   s   | j S )zThe value of the Enum member.)r[   )r$   r   r   r   r/   W  s    z
Enum.valueNc                sž   t tj| ƒ}ˆrt ˆƒ‰n|‰‡ ‡fdd„ˆjƒ D ƒ}y|jdd„ d� W n$ tk
rp   |jdd„ d� Y nX | |||d�} t| _|j| j	ƒ | ||< | S )z[
        Create a new Enum subclass that replaces a collection of global constants
        c                s    g | ]}ˆ |ƒr|ˆ| f‘qS r   r   )rK   r   )ÚfilterÚsourcer   r   r±   q  s   z!Enum._convert.<locals>.<listcomp>c             S   s   | d | d fS )Nr    r   r   )Útr   r   r   Ú<lambda>v  s    zEnum._convert.<locals>.<lambda>)rA   c             S   s   | d S )Nr   r   )r¹   r   r   r   rº   y  s    )r‚   )
Úvarsrœ   ÚmodulesÚkeysÚsortr#   Ú_reduce_ex_by_namer'   ÚupdaterŽ   )r)   r   r‚   r·   r¸   Úmodule_globalsÚmembersr   )r·   r¸   r   Ú_convert\  s    

zEnum._convert)N)r+   r(   r,   r-   re   r8   r¬   r9   r\   r]   r�   r^   r¶   r'   r   r   r/   rÃ   r   r   r   r   r   ÿ  s   		
)Ú	metaclassc               @   s   e Zd ZdZdS )r	   z.Enum where members are also (and must be) intsN)r+   r(   r,   r-   r   r   r   r   r	   �  s   c             C   s   | j S )N)r   )r$   r%   r   r   r   r¿   …  s    r¿   c               @   sp   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r
   zSupport for flagsc             C   sd   |s|dk	r|S dS xBt |ƒD ]6}yt|ƒ}P W q tk
rR   td| ƒd‚Y qX qW d|d  S )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    zInvalid Flag value: %rr   )r•   Ú	_high_bitÚ	Exceptionr#   )r   r…   r¢   r¡   r°   Úhigh_bitr   r   r   r8   ‹  s    	zFlag._generate_next_value_c             C   s.   |}|dk r| }| j |ƒ}|dk r*| }|S )Nr   )r7   )r)   r/   Úoriginal_valueÚpossible_memberr   r   r   r9   ž  s    
zFlag._missing_c             C   sb   | j j|dƒ}|dkr^t| |ƒ\}}|r:td|| jf ƒ‚tj| ƒ}d|_||_| j j	||ƒ}|S )zL
        Create a composite member iff value contains only members.
        Nz%r is not a valid %s)
ri   r—   Ú
_decomposer<   r+   rj   re   rm   r[   Ú
setdefault)r)   r/   Úpseudo_memberr   Úextra_flagsr   r   r   r7   ¨  s    
zFlag._create_pseudo_member_c             C   s"   t || jƒstS |j| j@ |jkS )N)r>   r5   ÚNotImplementedr[   )r$   Úotherr   r   r   rŠ   ¼  s    zFlag.__contains__c             C   sV   | j }| jd k	r$d|j| j| jf S t|| jƒ\}}d|jdjdd„ |D ƒƒ| jf S )Nz<%s.%s: %r>ú|c             S   s   g | ]}t |jp|jƒ‘qS r   )rp   rm   r[   )rK   rY   r   r   r   r±   È  s    z!Flag.__repr__.<locals>.<listcomp>)r5   rm   r+   r[   rÊ   rd   )r$   r)   rÂ   Ú	uncoveredr   r   r   r\   Á  s    
zFlag.__repr__c             C   s€   | j }| jd k	r d|j| jf S t|| jƒ\}}t|ƒdkr^|d jd kr^d|j|d jf S d|jdjdd„ |D ƒƒf S d S )Nz%s.%sr    r   z%s.%rrÐ   c             S   s   g | ]}t |jp|jƒ‘qS r   )rp   rm   r[   )rK   rY   r   r   r   r±   Ö  s    z Flag.__str__.<locals>.<listcomp>)r5   rm   r+   rÊ   r[   r   rd   )r$   r)   rÂ   rÑ   r   r   r   r]   Ì  s    
zFlag.__str__c             C   s
   t | jƒS )N)Úboolr[   )r$   r   r   r   r�   Ù  s    zFlag.__bool__c             C   s"   t || jƒstS | j| j|jB ƒS )N)r>   r5   rÎ   r[   )r$   rÏ   r   r   r   Ú__or__Ü  s    zFlag.__or__c             C   s"   t || jƒstS | j| j|j@ ƒS )N)r>   r5   rÎ   r[   )r$   rÏ   r   r   r   Ú__and__á  s    zFlag.__and__c             C   s"   t || jƒstS | j| j|jA ƒS )N)r>   r5   rÎ   r[   )r$   rÏ   r   r   r   Ú__xor__æ  s    zFlag.__xor__c                sD   t ˆjˆjƒ\‰ }‡ ‡fdd„ˆjD ƒ}tt|ˆjdƒƒ}ˆj|ƒS )Nc                s&   g | ]}|ˆ kr|j ˆj @  r|‘qS r   )r[   )rK   rY   )rÂ   r$   r   r   r±   î  s    z#Flag.__invert__.<locals>.<listcomp>r   )rÊ   r5   r[   r   Ú_or_)r$   rÑ   Úinverted_membersÚinvertedr   )rÂ   r$   r   Ú
__invert__ë  s    zFlag.__invert__N)r+   r(   r,   r-   r8   r¬   r9   r7   rŠ   r\   r]   r�   rÓ   rÔ   rÕ   rÙ   r   r   r   r   r
   ˆ  s   
c               @   sT   e Zd ZdZedd„ ƒZedd„ ƒZdd„ Zdd	„ Zd
d„ Z	eZ
eZe	Zdd„ ZdS )r   zSupport for integer-based Flagsc             C   s*   t |tƒstd|| jf ƒ‚| j|ƒ}|S )Nz%r is not a valid %s)r>   Úintr<   r+   r7   )r)   r/   Ú
new_memberr   r   r   r9   ø  s    

zIntFlag._missing_c             C   s´   | j j|d ƒ}|d kr°|g}t| |ƒ\}}xL|rvt|ƒ}d| }|| j kr\||kr\|j|ƒ || krld}q,||N }q,W x6t|ƒD ]*}tj| |ƒ}d |_||_	| j j
||ƒ}q‚W |S )Nr   r   )ri   r—   rÊ   rÅ   r?   r•   rÚ   re   rm   r[   rË   )r)   r/   rÌ   Úneed_to_creater   rÍ   ÚbitÚ
flag_valuer   r   r   r7   ÿ  s&    


zIntFlag._create_pseudo_member_c             C   s0   t || jtfƒstS | j| j| j|ƒjB ƒ}|S )N)r>   r5   rÚ   rÎ   r[   )r$   rÏ   Úresultr   r   r   rÓ     s    zIntFlag.__or__c             C   s,   t || jtfƒstS | j| j| j|ƒj@ ƒS )N)r>   r5   rÚ   rÎ   r[   )r$   rÏ   r   r   r   rÔ   #  s    zIntFlag.__and__c             C   s,   t || jtfƒstS | j| j| j|ƒjA ƒS )N)r>   r5   rÚ   rÎ   r[   )r$   rÏ   r   r   r   rÕ   (  s    zIntFlag.__xor__c             C   s   | j | j ƒ}|S )N)r5   r[   )r$   rß   r   r   r   rÙ   1  s    zIntFlag.__invert__N)r+   r(   r,   r-   r¬   r9   r7   rÓ   rÔ   rÕ   Ú__ror__Ú__rand__Ú__rxor__rÙ   r   r   r   r   r   õ  s   c             C   s   | j ƒ d S )z@returns index of highest bit, or -1 if value is zero or negativer    )Ú
bit_length)r/   r   r   r   rÅ   6  s    rÅ   c             C   sb   g }x0| j jƒ D ]"\}}||jkr|j||jfƒ qW |r^djdd„ |D ƒƒ}td| |f ƒ‚| S )z?Class decorator for enumerations ensuring unique member values.z, c             S   s   g | ]\}}d ||f ‘qS )z%s -> %sr   )rK   Úaliasr   r   r   r   r±   B  s    zunique.<locals>.<listcomp>z duplicate values found in %r: %s)rŽ   rR   r   r?   rd   r<   )ÚenumerationÚ
duplicatesr   r‰   Úalias_detailsr   r   r   r   :  s    
c             C   sÚ   |}|dk }|r*dd„ t | jjƒ ƒD ƒ}ndd„ t | jjƒ ƒD ƒ}g }x4|D ],\}}|rL||@ |krL|j|ƒ || M }qLW | rœ|| jkrœ|j| j| ƒ |jdd„ dd� t|ƒd	krÒ|d j|krÒ|jdƒ ||fS )
z#Extract all members from the value.r   c             S   s"   g | ]\}}|j d k	r||f‘qS )N)r   )rK   rT   rY   r   r   r   r±   R  s   z_decompose.<locals>.<listcomp>c             S   s*   g | ]"\}}|j d k	st|ƒr||f‘qS )N)r   Ú_power_of_two)rK   rT   rY   r   r   r   r±   Y  s   c             S   s   | j S )N)r[   )rY   r   r   r   rº   d  s    z_decompose.<locals>.<lambda>T)rA   Úreverser    )rš   ri   rR   r?   r¾   r   r/   ra   )Úflagr/   Únot_coveredÚnegativeÚflags_to_checkrÂ   r‰   r¤   r   r   r   rÊ   G  s$    

rÊ   c             C   s   | dk rdS | dt | ƒ kS )Nr    Fr   )rÅ   )r/   r   r   r   rè   j  s    rè   )#rœ   Útypesr   r   Ú	functoolsr   Úoperatorr   rÖ   Ú_collectionsr   ÚImportErrorÚcollectionsÚ__all__r   r   r"   r*   rj   r.   r   Údictr0   r   r„   r   rÚ   r	   r¿   r
   r   rÅ   r   rÊ   rè   r   r   r   r   Ú<module>   s@   3    mA#