
    ujhB                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
  ej                  e      Zd Zd ZddZ	 	 dd	d
dededeeef   dedef
dZy)    N)PathLike)Path)Uniondownload_url_to_filec                     t        t        j                  j                               dz  t        |       z  }|j                  j                  dd       |S )N
torchaudioT)parentsexist_ok)r   torchhubget_dirparentmkdir)keypaths     W/var/www/html/dev/engine/venv/lib/python3.12/site-packages/torchaudio/utils/download.py_get_local_pathr      sC    		!!#$|3d3i?DKKdT2K    c                 *    d|  }t        |||       y )Nz(https://download.pytorch.org/torchaudio/progressr   )r   r   r   urls       r   	_downloadr      s    4SE
:CdX6r   c                    t        j                         }t        | d      5 }|j                  |      }|r%|j	                  |       |j                  |      }|r%d d d        |j                         S # 1 sw Y   |j                         S xY w)Nrb)hashlibsha256openreadupdate	hexdigest)r   hash
chunk_sizemfiledatas         r   	_get_hashr(      su    A	dD	 )Tyy$HHTN99Z(D )
 ;;=)
 ;;=s   8A22B
Tr   r   r#   r   r   returnc          	      r   |xs t        |       }|j                         rt        j                  d|       n%t        j                  d| |       t	        | ||       |rPt        j                  d       t        ||      }||k7  rt        d| d| d| d      t        j                  d	       t        |      S )
a4  Download and store torchaudio assets to local file system.

    If a file exists at the download path, then that path is returned with or without
    hash validation.

    Args:
        key (str): The asset identifier.
        hash (str, optional):
            The value of SHA256 hash of the asset. If provided, it is used to verify
            the downloaded / cached object. If not provided, then no hash validation
            is performed. This means if a file exists at the download path, then the path
            is returned as-is without verifying the identity of the file.
        path (path-like object, optional):
            By default, the downloaded asset is saved in a directory under
            :py:func:`torch.hub.get_dir` and intermediate directories based on the given `key`
            are created.
            This argument can be used to overwrite the target location.
            When this argument is provided, all the intermediate directories have to be
            created beforehand.
        progress (bool): Whether to show progress bar for downloading. Default: ``True``.

    Note:
        Currently the valid key values are the route on ``download.pytorch.org/torchaudio``,
        but this is an implementation detail.

    Returns:
        str: The path to the asset on the local file system.
    z2The local file (%s) exists. Skipping the download.zDownloading %s to %sr   zVerifying the hash value.z'The hash value of the downloaded file (z), 'z+' does not match the provided hash value, 'z'.zHash validated.)r   exists_LGinfor   r(   
ValueErrorstr)r   r#   r   r   digests        r   download_assetr1   "   s    F '?3'D{{}EtL'd3#th/,-4&T>9$tF8 L--1F"6 
 	"#t9r   )i  ) r2   )r   loggingosr   pathlibr   typingr   r   torchaudio._internalr   	getLogger__name__r,   r   r   r(   r/   boolr1    r   r   <module>r<      s          5g!7
 !#7
 7	7
7 X
7
 7 	7r   