U
    Ze                     @   s  d Z ddlZddlZddlZddlZddlZddlZddddddd	d
dddddgZe	e
 e	e
 kZejdd dk rd2ddZn
d3ddZzddlZdd ZW n ek
r   dd ZY nX dd Zejdk rd4ddZn
d5ddZeed re	Ze	Zne	Ze	ZG dd dZG dd dZd d	 Zd!d
 ZejdkrJd6d#dZn
d7d$dZejdd d%krrd&d' Zn4zdd(lmZ W n ek
r   d)ZY nX d*d' Zejdd d+k rd,d Znd-d Zejdd dk rd8d/dZn
d9d0dZd:d1dZ dS );zP
This module contains fixups for using nose under different versions of Python.
    Nmake_instancemethod
cmp_to_key	sort_list	ClassTypeTypeTypeUNICODE_STRINGSunbound_methodismethodbytes_is_base_exceptionforce_unicodeexc_to_unicodeformat_exception      r   UTF-8c                 C   s6   zt | } W n$ tk
r0   t | |d} Y nX | S )Nreplace)strUnicodeDecodeErrordecodesencoding r   m/mounts/lovelace/software/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/nose/pyversion.pyr      s
    c                 C   s   t | S Nr   r   r   r   r   r      s    c                 C   s   t | j||jS r   )newZinstancemethod__func__	__class__functioninstancer   r   r   r   %   s    
c                 C   s   |  ||jS r   )__get__r    r!   r   r   r   r   )   s    c                    s   G  fdddt }|S )z,Convert a cmp= function into a key= functionc                       s8   e Zd Zdd Z fddZ fddZ fddZd	S )
zcmp_to_key.<locals>.Keyc                 S   s
   || _ d S r   obj)selfr&   r   r   r   __init__2   s    z cmp_to_key.<locals>.Key.__init__c                    s    | j |j dk S Nr   r%   r'   othermycmpr   r   __lt__4   s    zcmp_to_key.<locals>.Key.__lt__c                    s    | j |j dkS r)   r%   r*   r,   r   r   __gt__6   s    zcmp_to_key.<locals>.Key.__gt__c                    s    | j |j dkS r)   r%   r*   r,   r   r   __eq__8   s    zcmp_to_key.<locals>.Key.__eq__N)__name__
__module____qualname__r(   r.   r/   r0   r   r,   r   r   Key1   s   r4   )object)r-   r4   r   r,   r   r   /   s    	)r      Fc                    s,   |r|   fddS |   fddS d S )Nc                    s   t  | | S r   cmpabkeyr   r   <lambda>A       zsort_list.<locals>.<lambda>c                    s   t  |  |S r   r7   r9   r<   r   r   r>   C   r?   sortlr=   reverser   r<   r   r   ?   s    c                 C   s   | j ||dS )N)r=   rD   r@   rB   r   r   r   r   E   s    c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )UnboundMethodc                 C   s@   |j  | _ || _t|| _tjdk r.|| j_t|dd | _	d S )Nr   __doc__)
__dict__copy_funcUnboundSelf__self__sysversion_infor    getattrrF   )r'   clsfuncr   r   r   r(   V   s    

zUnboundMethod.__init__c                 C   sX   | j j}|j}tj| }t|dd }|d k	r8tj|}t	j
||d|j| jjf fS )N__file__z%s.%s)rK   rO   r2   rL   modulesrN   ospathabspathnoseutilsrcr1   rI   )r'   rO   modnamemodulefilenamer   r   r   address`   s    
zUnboundMethod.addressc                 O   s   | j ||S r   )rI   )r'   argskwargsr   r   r   __call__j   s    zUnboundMethod.__call__c                 C   s   t | j|S r   )rN   rI   r'   attrr   r   r   __getattr__m   s    zUnboundMethod.__getattr__c                 C   s   d| j jj| jjf S )Nz<unbound method %s.%s>)rK   rO   r1   rI   )r'   r   r   r   __repr__p   s    
zUnboundMethod.__repr__N)r1   r2   r3   r(   r\   r_   rb   rc   r   r   r   r   rE   U   s
   

rE   c                   @   s   e Zd Zdd Zdd ZdS )rJ   c                 C   s
   || _ d S r   )rO   )r'   rO   r   r   r   r(   u   s    zUnboundSelf.__init__c                 C   s   |dkr| j S t| |S d S )Nr    )rO   r5   __getattribute__r`   r   r   r   rd   z   s    zUnboundSelf.__getattribute__N)r1   r2   r3   r(   rd   r   r   r   r   rJ   t   s   rJ   c                 C   s4   t |r|S t |s*tdt|f t| |S )Nz%s is not a function)inspectr	   
isfunction	TypeErrorreprrE   )rO   rP   r   r   r   r      s
    

c                 C   s   t | pt| tS r   )re   r	   
isinstancerE   r%   r   r   r   r	      s    utf8c                 C   s   t | tr| S t| |S r   )ri   bytesr   r   r   r   r
      s    
c                 C   s   t | S r   r   r   r   r   r   r
      s    )r      c                 C   s$   t | tr| j} t| p"t| S r   )ri   rE   rI   re   isgeneratorfunctionisgenerator)or   r   r   rn      s    
rn   )CO_GENERATOR    c                 C   s.   z| j jt@ dkW S  tk
r(   Y dS X d S )Nr   F)__code__co_flagsrp   AttributeError)rP   r   r   r   rn      s    )r      c                 C   s
   t | tS r   )ri   	Exceptionexcr   r   r   r      s    c                 C   s
   t | tS r   )ri   BaseExceptionrw   r   r   r   r      s    utf-8c                 C   s   t | rft| dsxt| ds6t| jr0| jd p2d}n| j}t||d}t| jj|d}d||f } nt| t	sxt
| } t| |dS )N__unicode__messager    )r   z%s: %s)r   hasattrlenr]   r|   r   r    r1   ri   r   rh   )evr   msgclsnamer   r   r   r      s    


c                 C   s   t | S r   r   )r   r   r   r   r   r      s    c                 C   sR   | \}}}t |s8tdt||}t|}|| S tdtj|  |S d S )Nr}   )r   r   join	traceback	format_tbr   r   )exc_infor   ecr   tbtb_datar   r   r   r      s    
)r   )r   )F)F)rj   )N)rz   )rz   )r   )!rF   rL   rS   r   typesre   Z	nose.utilrV   __all__typer   r   rM   r   r   r   ImportErrorr   r   r~   r   r   rE   rJ   r   r	   r
   rn   Zcompiler.constsrp   r   r   r   r   r   r   r   <module>   sp         







