ó
î–+[c           @   ss   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d „  Z d „  Z d „  Z d Z	 d d „ Z d S(   s   
Disk management utilities.
iÿÿÿÿNc         C   s   d } xx t  j |  ƒ d g D]` } t  j t  j j |  | ƒ ƒ } t | d ƒ rd | | j d 7} q | | j d d d 7} q Wt | d ƒ S(   s&    Return the disk usage in a directory.i    t   .t	   st_blocksi   i   g      @(	   t   ost   listdirt   statt   patht   joint   hasattrR   t   st_sizet   int(   R   t   sizet   fileR   (    (    sS   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/site_packages/joblib2/disk.pyt	   disk_used   s    c         C   s…   d } t  d d d | d | d ƒ } y& t | |  d t |  d  ƒ ƒ } Wn3 t t f k
 r€ t d |  t |  ƒ f ƒ ‚ n X| S(	   s7    Convert a memory text to it's value in kilobytes.
    i   t   Ki   t   Mt   Gi   iÿÿÿÿsQ   Invalid literal for size give: %s (type %s) should be alike '10G', '500M', '50K'.(   t   dictR	   t   floatt   KeyErrort
   ValueErrort   type(   t   textt   kilot   unitsR
   (    (    sS   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/site_packages/joblib2/disk.pyt   memstr_to_kbytes"   s    &c         C   sC   y t  j |  ƒ Wn+ t k
 r> } | j t j k r? ‚  q? n Xd S(   sg   Ensure directory d exists (like mkdir -p on Unix)
    No guarantee that the directory is writable.
    N(   R   t   makedirst   OSErrort   errnot   EEXIST(   t   dt   e(    (    sS   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/site_packages/joblib2/disk.pyt   mkdirp1   s
    gš™™™™™¹?c         C   s+  g  } y t  j |  ƒ } WnA t  j k
 r\ } | d k	 rV | t  j |  t j ƒ  ƒ q] ‚  n XxÇ | D]¿ } t  j j |  | ƒ } t  j j | ƒ rd | d k	 r³ t	 j
 | t | ƒ q#d } xg t ry t	 j
 | t d ƒ PWq¼ t  j k
 r} | d k r‚  n  | d 7} t j t ƒ q¼ Xq¼ Wqd qd Wd S(   sÌ  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.
    i    i   N(   R   R   t   errort   Nonet   syst   exc_infoR   R   t   isdirt   shutilt   rmtreet   Falset   Truet   timet   sleept   RM_SUBDIRS_RETRY_TIME(   R   t   onerrort   namest   errt   namet   fullnamet	   err_count(    (    sS   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/site_packages/joblib2/disk.pyt
   rm_subdirsA   s,    	
(   t   __doc__R   R   R%   R"   R)   R   R   R   R+   R!   R2   (    (    (    sS   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/site_packages/joblib2/disk.pyt   <module>   s   			