
    Q/Ph                     ^    d Z ddlZddlmZ ddlmZ ddlmZ de	de	defd	Z
de	de	defd
ZdS )zDataset cache utility functions    N)Path)get)get_data_path	file_nameurlreturnc                     t                      }|                    d           || z  }|                                s?t          |d          }|                                 |                    |j                   |S )Check if file_name already is in the data path, otherwise download it from url.

    Args:
        file_name: the file name
        url: the URL of the dataset

    Returns:
        The relative path to the dataset
    T)exist_ok)allow_redirects)r   mkdirexistsget_fileraise_for_statuswrite_bytescontent)r   r   	data_path	file_pathresponses        [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ydata_profiling/utils/cache.py
cache_filer   
   s     IOOTO"""I%I  0C666!!###h.///    c                 ,   t                      }|| z  }|                                slt          d|          }t          j        |d          5 }|                    |j        |           ddd           n# 1 swxY w Y   |                                 |S )r
   ztmp.ziprN)r   r   r   zipfileZipFileextractnameunlink)r   r   r   r   tmp_pathzip_files         r   cache_zipped_filer"   $   s     II%I  i--_Xs++ 	8xY^Y777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	s   A55A9<A9)__doc__r   pathlibr   requestsr   r   ydata_profiling.utils.pathsr   strr   r"    r   r   <module>r)      s    % %        $ $ $ $ $ $ 5 5 5 5 5 5# C D    4 3 4      r   