
    .Ph                         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 n# e	$ r e
ZY nw xY wd Zd Zd ZdZdZdd	ZddZdS )z
Disk management utilities.
    N)utilc                 &   d}t          j        |           dgz   D ]e}t          j        t           j                            | |                    }t          |d          r||j        dz  z  }R||j        dz  dz   dz  z  }ft          |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       K/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/joblib/disk.py	disk_usedr      s    D
4  C5( 4 4wrw||D$//004%% 	4DNS((DD T\S(1,33DD tf}    c           	         d}t          ||dz  |dz            }	 t          || d                  t          | dd                   z            }n=# t          t          f$ r)}t	          d| dt          |           d	          |d}~ww xY w|S )
z,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447dAg...E5b?U49%5%5566j!   j-1TT4::::?
 
 	
 Ks   3A B
!$BB
c                     	 t          j        |            dS # t          $ r!}|j        t          j        k    r Y d}~dS 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,   5   s]    
A   7el"" #"""""s    
A>Ag?
   c                 $   g }	 t          j        |           }nA# t           j        $ r/ |) |t           j        | t          j                               n Y nw xY w|D ]3}t           j                            | |          }t          ||           4d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.
    N)onerror)r   r	   errorsysexc_infor   r   delete_folder)r   r/   namesnamefullnames        r   
rm_subdirsr7   H   s      E
4  8   GBJclnn5555 65  1 17<<d++h000001 1s    ;AATc                 6   t           j                            |           r|t          j        | d|           dS d}	 t          j        |           }	 t          |          dk    s|r@t          j        | dd           t          j        d	                    |                      dS t          d	                    | t          |                              # t          t          f$ r |dz  }|t          k    r Y nw xY wt          j        t                     dS )	zBUtility function to cleanup a temporary folder if it still exists.NFr   T)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   f   s=   	w}}[!! 2M+ug66666 I2
;//5zzQ/kPTUUUU
#<#C#CK#P#PQQQ%HOO +SZZ   
  .   NI #555 	 65 
0111)22 2s   AC '0C "C<;C<)N)NT)__doc__r)   r   r;   r1   rB   multiprocessingr   r@   	NameErrorr(   r   r%   r,   rD   rA   r7   r3    r   r   <module>rM      s      				  



             LL   LLL          1 1 1 1<2 2 2 2 2 2s   ! ++