
    sKg%                         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mZ 	 e d Zd Zd ZdZdZdd	Zdd
Zy# e	$ r e
ZY w xY w)z
Disk management utilities.
    N)utilc                 2   d}t        j                  |       dgz   D ]l  }t        j                  t         j                  j	                  | |            }t        |d      r||j                  dz  z  }U||j                  dz  dz   dz  z  }n t        |dz        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
   s       O/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/joblib/disk.py	disk_usedr      s    D

4 C5(wwrww||D$/04%DNNS((D T\\S(1,33D ) te|    c           	          d}t        ||dz  |dz        }	 t        || d      t        | dd       z        }|S # t        t        f$ r!}t	        d| dt        |       d	      |d}~ww xY w)
z2 Convert a memory text to its value in bytes.
    i         )KMGNzInvalid literal for size give: z (type z') should be alike '10G', '500M', '50K'.)dictr   floatKeyError
ValueErrortype)textkilounitsr   es        r   memstr_to_bytesr%   *   s     D4419	2EG5b?U49%556
 K	 j! G-14:?@EF	GGs    : A*	A%%A*c                     	 t        j                  |        y# t        $ r(}|j                  t        j                  k7  r Y d}~yd}~ww xY w)zgEnsure directory d exists (like mkdir -p on Unix)
    No guarantee that the directory is writable.
    N)r   makedirsOSErrorerrnoEEXIST)dr$   s     r   mkdirpr,   8   s:    
A 77ell" #s    	A	AA	g?
   c                 *   g }	 t        j                  |       }|D ]/  }t         j
                  j                  | |      }t        ||       1 y# t         j                  $ r1 |+ |t         j                  | t        j                                n Y xw xY w)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.
    N)onerror)r   r	   errorsysexc_infor   r   delete_folder)r   r/   namesnamefullnames        r   
rm_subdirsr7   K   s      E

4  77<<d+h0  88 BJJclln5 6s   A ABBc                    t         j                  j                  |       r|t        j                  | d|       yd}	 t        j
                  |       }	 t        |      dk(  s|r=t        j                  | dd       t        j                  dj                  |              yt        dj                  | t        |                  y# t        t        f$ r |dz  }|t        kD  r Y nw xY wt        j                  t               )zBUtility function to cleanup a temporary folder if it still exists.NFr   )ignore_errorsr/   zSuccessfully deleted {}z*Expected empty folder {} but got {} files.r   )r   r   isdirshutilrmtreer	   lenr   debugformatr(   WindowsErrorRM_SUBDIRS_N_RETRYtimesleepRM_SUBDIRS_RETRY_TIME)folder_pathr/   allow_non_empty	err_countfiless        r   r3   r3   i   s    	ww}}[!MM+ug6 I

;/5zQ/'ud 

5<<[IK%%%+VKU%D % ",  . NI #55 	 6 

01- s   AC  $C C&%C&)N)NT)__doc__r   r1   rB   r)   r;   multiprocessingr   r@   	NameErrorr(   r   r%   r,   rD   rA   r7   r3    r   r   <module>rM      sd    
 
     
    1<2g  Ls   6 A A 