o
    jl                     @   s  d Z ddlZg dZedejdd  Zze W n ey&   dd ZY nw G dd	 d	e	Z
d
d Zdd Zdd Zdd ZG dd deZdZG dd deZi Zded< dd Zeed< [dd Zeed< [dd Zeed< [dd Zeed< [d d! Zeed!< [ed"k rd#d$ Zeed$< [n$d%d& Zeed&< [d'd( Zeed(< [d)d* Zeed*< [d+d, Zeed,< [d-d. Zeed.< [d/d0 Z e ed0< [ d1d2 Z!e!ed2< [!d3d4 Z"e"ed4< ["e
d5d6 Z#e#ed6< [#e
d7d8 Z$e$ed8< [$ed9e	feZ[G d:d; d;e%eZ&d<d= Z'dS )>zPython Enumerations    N)EnumIntEnumunique%s.%s   c                 C   s   | D ]}|r	 dS qdS )NTF )iterableelementr   r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/dcerpc/v5/enum.pyany   s
   r   c                   @   s4   e Zd ZdZdddZdddZdd Zd	d
 ZdS )_RouteClassAttributeToGetattraj  Route attribute access on a class to __getattr__.

    This is a descriptor, used to define attributes that act differently when
    accessed through an instance and through a class.  Instance access remains
    normal, but access to an attribute through a class will be routed to the
    class's __getattr__ method; this is done by raising AttributeError.

    Nc                 C   s
   || _ d S N)fget)selfr   r   r   r
   __init__      
z&_RouteClassAttributeToGetattr.__init__c                 C   s   |d u rt  | |S r   )AttributeErrorr   )r   instance
ownerclassr   r   r
   __get__   s   
z%_RouteClassAttributeToGetattr.__get__c                 C      t d)Nzcan't set attributer   )r   r   valuer   r   r
   __set__$      z%_RouteClassAttributeToGetattr.__set__c                 C   r   )Nzcan't delete attributer   )r   r   r   r   r
   
__delete__'   r   z(_RouteClassAttributeToGetattr.__delete__r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r
   r      s    

r   c                 C   s   t | dpt | dpt | dS )z5Returns True if obj is a descriptor, False otherwise.r   r   r   )hasattr)objr   r   r
   _is_descriptor+   s
   
r"   c                 C   sT   | dd | dd   kodkn  o)| dd dko)| dd dko)t | dkS )	z3Returns True if a __dunder__ name, False otherwise.Nr   __   _   lennamer   r   r
   
_is_dunder3   s   (
r-   c                 C   sL   | d | d   kodkn  o%| dd dko%| dd dko%t | dkS )z1Returns True if a _sunder_ name, False otherwise.r   r&      r   r#   r)   r+   r   r   r
   
_is_sunder;   s    
r0   c                 C   s   dd }|| _ d| _dS )z"Make the given class un-picklable.c                 S   s   t d|  )Nz%r cannot be pickled)	TypeErrorr   r   r   r
   _break_on_call_reduceE   s   z6_make_class_unpicklable.<locals>._break_on_call_reducez	<unknown>N)
__reduce__r   )clsr3   r   r   r
   _make_class_unpicklableC   s   
r6   c                       s,   e Zd ZdZ fddZ fddZ  ZS )	_EnumDictzTrack 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 t|   g | _d S r   )superr7   r   _member_namesr2   	__class__r   r
   r   R   s   
z_EnumDict.__init__c                    s   t dkr
|dkr
dS t|rtdt|rn!|| jv r"td| t|s8|| v r2td| |  | j| tt	| 
|| dS )a  Changes anything not dundered or not a descriptor.

        If a descriptor is added with the same name as an enum member, the name
        is removed from _member_names (this may leave a hole in the numerical
        sequence of values).

        If an enum member name is used twice, an error is raised; duplicate
        values are not checked for.

        Single underscore (sunder) names are reserved.

        Note:   in 3.x __order__ is simply discarded as a not necessary piece
                leftover from 2.x

              @	__order__Nz(_names_ are reserved for future Enum usezAttempted to reuse key: %rzKey already defined as: %r)pyverr0   
ValueErrorr-   r9   r1   r"   appendr8   r7   __setitem__)r   keyr   r:   r   r
   rA   V   s   
z_EnumDict.__setitem__)r   r   r   r   r   rA   __classcell__r   r   r:   r
   r7   K   s    r7   c                       s   e Zd ZdZedd Z fddZd'ddZd	d
 Z f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 fddZd'dd Zed!d" Zed#k rbed$d% Z  ZS ed&d% Z  ZS )(EnumMetazMetaclass for Enumc                 C   s   t  S r   )r7   )metaclsr5   basesr   r   r
   __prepare__      zEnumMeta.__prepare__c              	      s  t tu r}t | D ]\}}||< q| |\}}| ||\}	}
}tfddjD }jD ]}|= q8d  d u rTj tdk rQd}n!d}nd= d}tdk rr 	dd
   fd	d
|D } |7  t|tdg@ }|rtdd|f tt| | ||g _i _|_i _|tur|jdd u rt |	d u rj}	 D ]{}|| }t|ts|f}n|}|tu r|f}|r|s|	}t|ds||_n|	g|R  }t|ds|| |_|j}||_|_|j|  j D ]\}}|j|jkr|} nqj | |j|< z|j|< W q t!y2   Y qw |sLdd
 t"fdd
jD dd dD _t#d urXt$dt#j% dD ]$}t&|}t&||d }t&||d }|d ur}||u r}t$|| qZtdk rt't(rt$dt&t(d ntdk rt't(rdD ]}t$|t&t(| qt#d ur|
rt$djd  t$dt#jd  S )Nc                 3   s    | ]	}| | fV  qd S r   r   ).0k)	classdictr   r
   	<genexpr>   s    z#EnumMeta.__new__.<locals>.<genexpr>r=   r<   FT, c                    s   g | ]}| vr|qS r   r   rI   r,   )r=   r   r
   
<listcomp>   s    z$EnumMeta.__new__.<locals>.<listcomp>mrozInvalid enum member name(s): %s, __getnewargs___value_c                 S   s   g | ]}|d  qS )r   r   )rI   er   r   r
   rP      s    c                    s   g | ]	}| j | fqS r   _member_map_rO   )
enum_classr   r
   rP      s    c                 S   s
   | d j S )Nr/   rT   )tr   r   r
   <lambda>   s   
 z"EnumMeta.__new__.<locals>.<lambda>)rB   )__repr____str__
__format__@__cmp__)__le____lt____gt____ge____eq____ne____hash____member_new____new__))typedictr7   items_get_mixins_
_find_new_r9   getr>   replacesplitsetr?   joinr8   rD   ri   _member_names_rW   _member_type__value2member_map_object__dict__r6   
isinstancetupler    rT   _name___objclass__r   r   r@   r1   sortedr   setattrrS   getattr
issubclassint)rE   r5   rF   rK   original_dictrJ   vmember_type
first_enumri   save_newuse_argsmembersr,   order_specifiedaliasesinvalid_namesmember_namer   argsenum_membercanonical_memberclass_method
obj_methodenum_methodmethodr:   )r=   rK   rX   r
   ri      s   













	
zEnumMeta.__new__Nc                 C   s&   |du r
|  | |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: `module`, if set, will be stored in
        the new class' __module__ attribute; `type`, if set, will be mixed in
        as the first base class.

        Note: if `module` is not set this routine will attempt to discover the
        calling module by walking the frame stack; if this is unsuccessful
        the resulting class will not be pickleable.

        N)modulerj   )ri   _create_)r5   r   namesr   rj   r   r   r
   __call__!  s   zEnumMeta.__call__c                 C   s   t || o
|j| jv S r   )ry   r,   rW   )r5   memberr   r   r
   __contains__6  s   zEnumMeta.__contains__c                    s,   || j v rtd| j tt| | d S )Nz%s: cannot delete Enum member.)rW   r   r   r8   rD   __delattr__)r5   attrr:   r   r
   r   9  s
   
zEnumMeta.__delattr__c                 C   s   g d| j  S )N)r;   r   __members__r   rt   r2   r   r   r
   __dir__A  s   zEnumMeta.__dir__c                 C   s
   | j  S )zReturns a mapping of member name->value.

        This mapping lists all enum members, including aliases. Note that this
        is a copy of the internal mapping.

        )rW   copyr5   r   r   r
   r   E  s   
zEnumMeta.__members__c                 C   s4   t |rt|z| j| W S  ty   t|w )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.

        )r-   r   rW   KeyErrorr5   r,   r   r   r
   __getattr__O  s   	zEnumMeta.__getattr__c                 C   s
   | j | S r   rV   r   r   r   r
   __getitem___  r   zEnumMeta.__getitem__c                    s    fdd j D S )Nc                 3       | ]} j | V  qd S r   rV   rO   r   r   r
   rL   c      z$EnumMeta.__iter__.<locals>.<genexpr>r   r   r   r   r
   __iter__b  s   zEnumMeta.__iter__c                    s    fddt  jD S )Nc                 3   r   r   rV   rO   r   r   r
   rL   f  r   z(EnumMeta.__reversed__.<locals>.<genexpr>)reversedrt   r   r   r   r
   __reversed__e     zEnumMeta.__reversed__c                 C   
   t | jS r   )r*   rt   r   r   r   r
   __len__h  r   zEnumMeta.__len__c                 C   s
   d| j  S )Nz	<enum %r>)r   r   r   r   r
   r\   k  r   zEnumMeta.__repr__c                    s4   | j di }||v rtdtt| || dS )zBlock 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.

        rW   zCannot reassign members.N)rx   ro   r   r8   rD   __setattr__)r5   r,   r   
member_mapr:   r   r
   r   n  s   zEnumMeta.__setattr__c              	   C   s.  | j }|du r| f}n|| f}|||}g }t|tr$|dd }t|ttfr;t|d tr;dd t|D }|D ]}	t|	trL|	||	 }
}n|	\}
}|||
< |	|
 q=t|	tsfd
||d< |||||}|du rz
tdjd	 }W n ttfy   Y nw |du rt| |S ||_|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 auto-numbered from 1.
        * An iterable of member names.  Values are auto-numbered from 1.
        * An iterable of (member name, value) pairs.
        * A mapping of member name -> value.

        NrM   rN   r   c                 S   s   g | ]
\}}||d  fqS )r/   r   )rI   irU   r   r   r
   rP         z%EnumMeta._create_.<locals>.<listcomp>r=   r   r   )r;   rG   ry   strrp   rq   rz   list	enumerater@   rs   ri   _sys	_getframe	f_globalsr   r?   r6   r   )r5   
class_namer   r   rj   rE   rF   rK   r=   itemr   member_valuerX   r   r   r
   r   {  s<   


zEnumMeta._create_c                 C   s   | rt du r
tt fS d }}| D ]}|t ur"t|t r"|jr"tdqt|t s,tdt| d t s?| d }| d }||fS | d jD ]}t|t rR|du rQ|}qD|du rX|}qD||fS )zReturns 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   rw   r   rt   r1   __mro__)rF   r   r   baser   r   r
   rm     s4   

zEnumMeta._get_mixins_r<   c                 C   s   |  dd}|r
dS tdd}ttd}tdu r|}ntjd }dD ]J}||fD ]=}z|j| }	W n ttfyB   t||d}	Y nw |	d|||fvre|dkrW|	| d<   dS t|	tra|		|}	|	} nq(|durl nq"tj
}|tj
u rxd}
nd}
|d|
fS )	  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__

            ri   N)NTTrh   ri   rh   )NFTFT)ro   r   rw   r   rx   r   r   ry   staticmethodr   ri   )rK   r   r   ri   N__new__O__new__E__new__r   possibletargetr   r   r   r
   rn     sJ   






zEnumMeta._find_new_c           	      C   s   |  dd}|du}|du r8dD ]$}||fD ]}t||d}|ddjtjtjfvr-|} nq|dur4 nqtj}|tju r@d}nd}|||fS )r   ri   Nr   FT)ro   r   ri   rw   r   )	rK   r   r   ri   r   r   r   r   r   r   r   r
   rn     s.   

)NNN)r   r   r   r   classmethodrG   ri   r   r   r   r   propertyr   r   r   r   r   r   r\   r   r   r   rm   r>   rn   rC   r   r   r:   r
   rD   }   s6    
 

	
5
-9rD   zNGeneric enumeration.

    Derive from this class to define new enumerations.

r   c                 C   sx   t || u r	|j}z|| jv r| j| W S W n ty2   | j D ]}|j|kr/|   Y S q"Y nw td|| jf )Nz%s is not a valid %s)rj   r   rv   r1   rW   valuesr?   r   )r5   r   r   r   r   r
   ri   Q  s   

ri   c                 C   s   d| j j| j| jf S )Nz<%s.%s: %r>)r;   r   r{   rT   r2   r   r   r
   r\   g  s   r\   c                 C   s   d| j j| jf S )Nr   )r;   r   r{   r2   r   r   r
   r]   m  s   r]   c                 C   s   dd | j jD }g d| S )Nc                 S   s   g | ]
}|d  dkr|qS )r   r&   r   )rI   mr   r   r
   rP   s  r   z__dir__.<locals>.<listcomp>)r;   r   r   r,   r   )r;   rx   )r   added_behaviorr   r   r
   r   r  s   r   c                 C   s0   | j tu rt}t| }n| j }| j}|||S r   )ru   rw   r   r   r^   )r   format_specr5   valr   r   r
   r^   x  s   

r^   r_   c                 C   s"   t || ju r| |u rdS dS tS )Nr   r.   )rj   r;   NotImplementedr1   r   r   otherr   r   r
   r`     s
   r`   c                 C      t d| jj|jjf )Nzunorderable types: %s() <= %s()r1   r;   r   r   r   r   r
   ra     r   ra   c                 C   r   )Nzunorderable types: %s() < %s()r   r   r   r   r
   rb     r   rb   c                 C   r   )Nzunorderable types: %s() >= %s()r   r   r   r   r
   rd     r   rd   c                 C   r   )Nzunorderable types: %s() > %s()r   r   r   r   r
   rc     r   rc   c                 C   s   t || ju r| |u S tS r   rj   r;   r   r   r   r   r
   re        re   c                 C   s   t || ju r| |uS tS r   r   r   r   r   r
   rf     r   rf   c                 C   s   | j fS r   rY   r2   r   r   r
   rS     r   rS   c                 C   r   r   )hashr{   r2   r   r   r
   rg     r   rg   c                 C      | j S r   )r{   r2   r   r   r
   r,     rH   r,   c                 C   r   r   rY   r2   r   r   r
   r     rH   r   r   c                   @   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    r   c                 C   s^   g }| j  D ]\}}||jkr|||jf q|r-ddd |D }td| |f | S )zIClass decorator that ensures only unique members exist in an enumeration.rR   c                 S   s   g | ]
\}}d ||f qS )z%s -> %sr   )rI   aliasr,   r   r   r
   rP     r   zunique.<locals>.<listcomp>zduplicate names found in %r: %s)r   rl   r,   r@   rs   r?   )enumeration
duplicatesr,   r   duplicate_namesr   r   r
   r     s   
r   )(r   sysr   __all__floatversion_infor>   r   	NameErrorrw   r   r"   r-   r0   r6   rk   r7   r   rj   rD   temp_enum_dictri   r\   r]   r   r^   r`   ra   rb   rd   rc   re   rf   rS   rg   r,   r   r   r   r   r   r   r   r
   <module>   s    /   T	

