a
    GDf;                     @   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lZg dZej	d dkZ
e Ze
reZeZeZeZeZdd Zdd Zn eZeZeZeZd	d Zd
d Ze
reZneZeedfddZe
reZeZeZeZeZeZnddlZefddZ e e!dd Ze e!dd Ze e!dd Ze e!dd Ze e!dd Ze e!dd Ze" dkrze#ej$dW n2 ey   Y n  e#y   dZ%e&e%Y n0 zddlm'Z' W n e(yL   zdd l)m*Z* W n  e(y   dd l+m*Z* Y n0 e,d!g d"Z-G d#d$ d$e.Z/efe0eee1e2dfe3e4e2e5fd%d&Z6d8d)d*Z'Y n0 zdd+l7m8Z8 W n* e(y   ej9ej:B dfd,d-Z8Y n0 zdd.l7m;Z; W n e(y   d9d0d1Z;Y n0 zdd2l<m=Z> W n$ e(y   G d3d4 d4eZ>Y n0 zdd5lm?Z? W n" e(y"   ej@d6d7 Z?Y n0 dS ):zModule which provides compatibility with older Python versions.
This is more future-compatible rather than the opposite (prefer latest
Python 3 way of doing things).
    N)PY3longrangesuperunicode
basestringub	lru_cachewhichget_terminal_sizeredirect_stderrFileNotFoundErrorPermissionErrorProcessLookupErrorInterruptedErrorChildProcessErrorFileExistsError   c                 C   s   | S N sr   r   [/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/psutil/_compat.pyr   2   s    r   c                 C   s
   |  dS )Nzlatin-1)encoder   r   r   r   r	   5   s    r	   c                 C   s
   t | dS )Nunicode_escape)r   r   r   r   r   r   >   s    c                 C   s   | S r   r   r   r   r   r   r	   A   s       c                 C   sd  | t u rHt|}z|j|jjd  }W n" ttfyL   d}t|Y n0 z
|j	}W nB t
tfy   z|jj	}W n t
y   d}t|Y n0 Y n0 |D ]} | j D ]}zNt|tjst|tr|j}qz
|j}W q t
y   ||| }Y q0 qW n t
tfy   Y qY n0 |j|ju r q4qq qHqd}t||t ur\t| |S t| S )zuLike Python 3 builtin super(). If called without any arguments
        it attempts to infer them at runtime.
        r   z'super() used in a function with no argsz$super() used in a non-newstyle classzsuper() called outside a method)	_SENTINELsys	_getframef_localsf_codeco_varnames
IndexErrorKeyErrorRuntimeError__mro__AttributeError	__class____dict__values
isinstancetypesFunctionTypepropertyfget__func____get__	TypeError	func_code_builtin_super)type_Ztype_or_objZ
framedepthfmsgmromethr   r   r   r   P   sH    







r   c                    s    fdd}|S )Nc                    s*   G  fddd j  _ j _ S )Nc                       s2   e Zd Z fddZG fdddeZ  ZS )zE_instance_checking_exception.<locals>.wrapped.<locals>.TemporaryClassc                    sh   t |dkrNt|d  rN|d }t|D ] }|ds*t| |t|| q*nt | j|i | d S )Nr   r   __)lenr+   dir
startswithsetattrgetattrr   __init__)selfargskwargsZ	unwrap_meattr)TemporaryClassr(   r   r   r@      s    

zN_instance_checking_exception.<locals>.wrapped.<locals>.TemporaryClass.__init__c                       s    e Zd Z fddZdd ZdS )zS_instance_checking_exception.<locals>.wrapped.<locals>.TemporaryClass.__metaclass__c                    s    |S r   r   )clsinstinstance_checkerr   r   __instancecheck__   s    ze_instance_checking_exception.<locals>.wrapped.<locals>.TemporaryClass.__metaclass__.__instancecheck__c                 S   s   t  d }t|| S Nr   )r   exc_infor+   )rF   Z	classinfovaluer   r   r   __subclasscheck__   s    ze_instance_checking_exception.<locals>.wrapped.<locals>.TemporaryClass.__metaclass__.__subclasscheck__N)__name__
__module____qualname__rJ   rN   r   rH   r   r   __metaclass__   s   rR   )rO   rP   rQ   r@   typerR   __classcell__r   rE   rI   )r(   r   rE      s   rE   )rO   __doc__rH   base_exceptionrU   r   wrapped   s    z-_instance_checking_exception.<locals>.wrappedr   )rX   rY   r   rW   r   _instance_checking_exception   s    rZ   c                 C   s   t | dttjkS Nerrno)r?   r   r\   ENOENTrG   r   r   r   r      s    r   c                 C   s   t | dttjkS r[   )r?   r   r\   ZESRCHr^   r   r   r   r      s    r   c                 C   s   t | dttjtjfv S r[   )r?   r   r\   EACCESEPERMr^   r   r   r   r      s    r   c                 C   s   t | dttjkS r[   )r?   r   r\   ZEINTRr^   r   r   r   r      s    r   c                 C   s   t | dttjkS r[   )r?   r   r\   ZECHILDr^   r   r   r   r      s    r   c                 C   s   t | dttjkS r[   )r?   r   r\   EEXISTr^   r   r   r   r      s    r   CPythonpermzbbroken or incompatible Python implementation, see: https://github.com/giampaolo/psutil/issues/1659)r
   )RLock	CacheInfo)hitsmissesmaxsizecurrsizec                   @   s$   e Zd ZdZefddZdd ZdS )
_HashedSeq	hashvaluec                 C   s   || d d < ||| _ d S r   rk   )rA   tuphashr   r   r   r@      s    z_HashedSeq.__init__c                 C   s   | j S r   rk   )rA   r   r   r   __hash__   s    z_HashedSeq.__hash__N)rO   rP   rQ   	__slots__rn   r@   ro   r   r   r   r   rj      s   rj   c	                    s   | }	|r.||  }
|	|7 }	|
D ]}|	|7 }	q |rl|	| fdd| D 7 }	|r|	| fdd|
D 7 }	n$||	dkr |	d |v r|	d S t|	S )Nc                 3   s   | ]} |V  qd S r   r   ).0vrS   r   r   	<genexpr>      z_make_key.<locals>.<genexpr>c                 3   s   | ]\}} |V  qd S r   r   )rq   krr   rs   r   r   rt     ru   r   r   )itemsrj   )rB   kwdstypedkwd_mark	fasttypessortedtuplerS   r;   keysorted_itemsitemr   rs   r   	_make_key   s    
r   d   Fc                    s    fdd}|S )zLeast-recently-used cache decorator, see:
        http://docs.python.org/3/library/functools.html#functools.lru_cache.
        c                    s  i ddgd\ t 
jtt 	g d d gd d < gd\dkrlfdd}nPd u r 
f	dd}n* 	
fdd} 	fdd	}	fd
d}|_||_||_t|S )Nr   )r   r   )r   r      r   c                     s"   | i |}   d7  < |S rK   r   )rB   rx   result)MISSESstatsuser_functionr   r   wrapper   s    z7lru_cache.<locals>.decorating_function.<locals>.wrapperc                     s\   | |}|}|ur2   d7  < |S | i |}||<   d7  < |S rK   r   )rB   rx   r~   r   )	HITSr   cache	cache_getmake_keyrootr   ry   r   r   r   r   '  s    
c                     s  |sr
| |}n| }	   z|}|d ur\}|\}}}}||< ||< | }| |< |< ||< ||<    d7  < |W 	  S W 	  n
	  0 | i |}	   z\}|v rnkr4|}	||	< ||	< |	  }d< | }
d  |< |< |
= |	|< n,| }||||g}| |<  |< |<   d7  < W 	  n
	  0 |S )Nr   r   )acquirerelease)rB   rx   r~   linkr   Z	link_prevZ	link_nextr   lastZoldrootZoldkey)r   KEYr   NEXTPREVRESULT_lenr   r   lockr   rh   nonlocal_rootr   ry   r   r   r   r   4  sR    
c                      s<      z$t   tW   S   0 dS )zReport cache statistics.N)r   
_CacheInfor;   r   r   )r   r   r   r   rh   r   r   r   
cache_infoa  s    z:lru_cache.<locals>.decorating_function.<locals>.cache_infoc                     sX      z@   d } | | ddg| dd< ddgdd< W   n
  0 dS )z%Clear the cache and cache statistics.r   N)r   clearr   )r   )r   r   r   r   r   r   cache_cleark  s    z;lru_cache.<locals>.decorating_function.<locals>.cache_clear)	r   getr;   rd   __wrapped__r   r   	functoolsupdate_wrapper)r   r   r   r   rh   ry   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   decorating_function  s,    *-
z&lru_cache.<locals>.decorating_functionr   )rh   ry   r   r   r   r   r
     s    ir
   )r   c                    s"  dd }t j r&| |r" S dS |du r>t jdt j}|sFdS |t j}tj	dkrt j
|vrt|dt j
 t jddt j}t fd	d
|D r g}q fdd|D }n g}t }|D ]P}t j|}||vr|| |D ](}	t j||	}
||
|r|
    S qqdS )aJ  Given a command, mode, and a PATH string, return the path which
        conforms to the given mode on the PATH, or None if there is no such
        file.

        `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
        of os.environ.get("PATH"), or can be overridden with a custom search
        path.
        c                 S   s&   t j| o$t | |o$t j|  S r   )ospathexistsaccessisdir)fnmoder   r   r   _access_check  s
    
zwhich.<locals>._access_checkNPATHwin32r   PATHEXT c                 3   s    | ]}   |  V  qd S r   )lowerendswithrq   extcmdr   r   rt     ru   zwhich.<locals>.<genexpr>c                    s   g | ]} | qS r   r   r   r   r   r   
<listcomp>  ru   zwhich.<locals>.<listcomp>)r   r   dirnameenvironr   defpathsplitpathsepr   platformcurdirinsertanysetnormcaseaddjoin)r   r   r   r   pathextfilesseenr<   normdirthefilenamer   r   r   r     s8    





r   )r   P      c                 C   sz   zdd l }dd l}dd l}W n ty2   |  Y S 0 z*|d|d|jd}|d |d fW S  tyt   |  Y S 0 d S )Nr   hhr   Z1234)fcntlstructtermiosImportErrorunpackZioctl
TIOCGWINSZ	Exception)fallbackr   r   r   resr   r   r   r     s    
r   )TimeoutExpiredc                   @   s   e Zd ZdS )SubprocessTimeoutExpiredN)rO   rP   rQ   r   r   r   r   r     s   r   )r   c                 c   s*   t j}z| t _| V  W |t _n|t _0 d S r   )r   stderr)
new_targetoriginalr   r   r   r     s
    r   )r   F)r   )ArV   collections
contextlibr\   r   r   r   r,   __all__version_infor   objectr   intr   r   xrangestrr   r   r   r	   r   r4   r   r   r   r   r   r   r   r   rZ   EnvironmentErrorpython_implementationOSErrorra   r7   r%   r
   r   	threadingrd   Zdummy_threading
namedtupler   listrj   r   	frozensetrS   r|   r}   r;   r   shutilr   F_OKX_OKr   
subprocessr   r   r   contextmanagerr   r   r   r   <module>   s   

;





	
r5