a
    +[                     @   sV   d Z ddlZddlZddlZddlZddlZdd Zdd Zdd Zd	Z	dd
dZ
dS )z
Disk management utilities.
    Nc                 C   sj   d}t | dg D ]H}t t j| |}t|drF||jd 7 }q||jd d d 7 }qt|d S )z& Return the disk usage in a directory.r   .	st_blocksi      g      @)	oslistdirstatpathjoinhasattrr   st_sizeint)r   sizefiler    r   O/home/psgendb/BIRCHDEV/pkg/quast-5.2.0/quast_libs/site_packages/joblib3/disk.py	disk_used   s    
r   c              	   C   sj   d}t d||d d}z$t|| d  t| dd  }W n* ttfyd   td| t| f Y n0 |S )z7 Convert a memory text to it's value in kilobytes.
    i   r      )KMGNzQInvalid literal for size give: %s (type %s) should be alike '10G', '500M', '50K'.)dictr   floatKeyError
ValueErrortype)textZkilounitsr   r   r   r   memstr_to_kbytes"   s    $

r   c              
   C   sF   zt |  W n2 ty@ } z|jtjkr, W Y d}~n
d}~0 0 dS )zgEnsure directory d exists (like mkdir -p on Unix)
    No guarantee that the directory is writable.
    N)r   makedirsOSErrorerrnoEEXIST)der   r   r   mkdirp1   s
    r%   g?c              
   C   s   g }zt | }W nD t jyV } z*|dur@|t j| t  n W Y d}~n
d}~0 0 |D ]}t j| |}t j|r\|durt	|d| q\d}zt	|dd W q\W q t jy   |dkrƂ |d7 }t
t Y q0 qq\dS )a  Remove all subdirectories in this path.

    The directory indicated by `path` is left in place, and its subdirectories
    are erased.

    If onerror is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If onerror is None,
    an exception is raised.
    NFr   r   )r   r   errorsysexc_infor   r	   isdirshutilrmtreetimesleepRM_SUBDIRS_RETRY_TIME)r   onerrornameserrnamefullnameZ	err_countr   r   r   
rm_subdirsA   s*    r4   )N)__doc__r!   r   r*   r'   r,   r   r   r%   r.   r4   r   r   r   r   <module>   s   
