
    *_j                         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 d dlmZ  ej	        e
          Zddedee         fdZded	edefd
Zd	edefdZd	edefdZdS )    N)Iterator)urlopenFcheck_writablereturnc              #     K   	 t           j        d         V  n# t          $ r Y nw xY wt           j        dk    r/t           j                            t          j        dd          V  d S g d}t          t          d          r |	                    dt          j                   |D ]}t           j                            |dd          }| r`t           j        
                    |          r!t          j        |t           j                  sdn t          j        |t           j                  s|V  t           j                            t           j                            d          d	d          V  d S )
NPYAV_TESTDATA_DIRntpyavdatasets)z/usr/local/sharez/usr/local/libz
/usr/sharez/usr/libreal_prefixr   ~z.pyav)osenvironKeyErrornamepathjoinsysprefixhasattrinsertexistsaccessW_OK
expanduser)r   basesbasedir_s       /data/video-pipeline/HaTramAudio/project/021-Ngay-Toi-Bi-Gach-Ten-Khoi-Gia-Pha/work/asr-venv/lib/python3.11/site-packages/av/datasets.pyiter_data_dirsr       sk     j,-----    
w$gll3:vz:::::  E sM"" $Q
### 	 	w||D&*55 	w~~d## yrw//  yrw// 




',,rw))#..
D
DDDDDDs    
&&urlr   c                    t           j                            |          }||k    rt          | d          t	                      D ]E}t           j                            ||          }t           j                            |          r|c S Ft          t	          d                    }t           j                            ||          }t          	                    d|  d|            t          |           }|                                dk    r$t          d|                                           t           j                            |          }	 t          j        |           n-# t          $ r }|j        t          j        k    r Y d}~nd}~ww xY w|dz   }t#          |d	          5 }t%          j        ||           ddd           n# 1 swxY w Y   t          j        ||           |S )
ag  Download the data at a URL, and cache it under the given name.

    The file is stored under `pyav/test` with the given name in the directory
    :envvar:`PYAV_TESTDATA_DIR`, or the first that is writeable of:

    - the current virtualenv
    - ``/usr/local/share``
    - ``/usr/local/lib``
    - ``/usr/share``
    - ``/usr/lib``
    - the user's home

    z is not normalized.TzDownloading z to    zHTTP Nz.tmpwb)r   r   normpath
ValueErrorr    r   r   nextloginfor   getcodedirnamemakedirsOSErrorerrnoEEXISTopenshutilcopyfileobjrename)	r!   r   
clean_namer   r   responseetmp_pathfhs	            r   cached_downloadr9   /   s#    !!$''JTD555666    w||D$''7>>$ 	KKK	 t$$%%D7<<d##DHH+C++T++,,,s||HS  5!1!1!3!3556667??4  D
D   7el"" #"""" f}H	h		 )8R((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) IhKs*   E( (
F2FF*GGGc           
          t          d| z   t          j                            d|                     dt          j        j                                      S )zDownload and return a path to a sample from the FFmpeg test suite.

    Data is handled by :func:`cached_download`.

    See the `FFmpeg Automated Test Environment <https://www.ffmpeg.org/fate.html>`_

    z"http://fate.ffmpeg.org/fate-suite/z
fate-suite/r9   r   r   r   replacesepr   s    r   fater@   `   sC     ,t3
\4<<RW[#A#ABB      c           
          t          d| z   t          j                            d|                     dt          j        j                                      S )zDownload and return a path to a sample that is curated by the PyAV developers.

    Data is handled by :func:`cached_download`.

    zhttps://pyav.org/datasets/zpyav-curatedr;   r<   r?   s    r   curatedrC   n   sC     $t+
^T\\#rw{%C%CDD  rA   )F)r.   loggingr   r1   r   collections.abcr   urllib.requestr   	getLogger__name__r(   boolstrr    r9   r@   rC    rA   r   <module>rL      s     				  



 $ $ $ $ $ $ " " " " " "g!! E  E4  EHSM  E  E  E  EF. .C .C . . . .bs s    	# 	# 	 	 	 	 	 	rA   