ó
    Eñi×#  ã                   ó¶   • S r SSKJr  SSKrSSKJr  SSKrSSKrSSKrSSK	J
r
Jr  SSK	JrJr   " S S	\5      r " S
 S\5      rSS jrSS jrSS jrS rS rg)z&Data downloading and reading functionsé    )ÚlogN)Úpathé   )Úappdata_dirÚresource_dirs)ÚStdoutProgressIndicatorÚurlopenc                   ó   • \ rS rSrSrSrg)ÚInternetNotAllowedErroré   zpPlugins that need resources can just use get_remote_file(), but
should catch this error and silently ignore it.
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/imageio/core/fetching.pyr   r      s   † ñò 	r   r   c                   ó   • \ rS rSrSrSrg)ÚNeedDownloadErroré   z‚Is raised when a remote file is requested that is not locally
available, but which needs to be explicitly downloaded by the user.
r   Nr   r   r   r   r   r      s   † ôr   r   c                 ó`  • SnX@-   n[         R                  " U 5      nUnU=(       d    [        S5      n[        5       nUR	                  SU5        U GH  n	[         R
                  " X–5      n
[         R                  " U
5      (       d  M7  U(       d¶  U(       a«  Xy:w  a¦  [        R                  R                  Xv5      n[         R                  " [         R                  " U5      5      (       d>  [        R                  " [         R                  " [         R                  " U5      5      5        [        R                  " X«5        Us  $ U
s  $ [        U[         5      (       d  GM  ["        R$                  " US5      n["        R&                  " [         R(                  " U
5      5      nXÜ:¼  a¶  U(       a«  Xy:w  a¦  [        R                  R                  Xv5      n[         R                  " [         R                  " U5      5      (       d>  [        R                  " [         R                  " [         R                  " U5      5      5        [        R                  " X«5        Us  $ U
s  $ [+        SU-  5          O   [        R,                  " SS5      R/                  5       S;   a  [1        S	5      eU(       d
  [3        5       e[         R
                  " X5      n
[         R                  " [         R                  " U
5      5      (       d>  [        R                  " [         R                  " [         R                  " U
5      5      5        [        R,                  " S
S5      (       a-  [5        S5       H  n [7        XZ5        U
s  $    [7        XZ5        U
$ [7        XZ5        U
$ ! [8         a    ["        R:                  " S5         MR  f = f)a)  Get a the filename for the local version of a file from the web

Parameters
----------
fname : str
    The relative filename on the remote data repository to download.
    These correspond to paths on
    ``https://github.com/imageio/imageio-binaries/``.
directory : str | None
    The directory where the file will be cached if a download was
    required to obtain the file. By default, the appdata directory
    is used. This is also the first directory that is checked for
    a local version of the file. If the directory does not exist,
    it will be created.
force_download : bool | str
    If True, the file will be downloaded even if a local copy exists
    (and this copy will be overwritten). Can also be a YYYY-MM-DD date
    to ensure a file is up-to-date (modified date of a file on disk,
    if present, is checked).
auto : bool
    Whether to auto-download the file if its not present locally. Default
    True. If False and a download is needed, raises NeedDownloadError.

Returns
-------
fname : str
    The path to the file on the local system.
z7https://github.com/imageio/imageio-binaries/raw/master/Úimageior   z%Y-%m-%dzFile older than %s, updating...ÚIMAGEIO_NO_INTERNETÚ )Ú1ÚtrueÚyeszeWill not download resource from the internet because environment variable IMAGEIO_NO_INTERNET is set.ÚCONTINUOUS_INTEGRATIONFé   g      à?)ÚopÚnormcaser   r   ÚinsertÚjoinÚisfileÚosr   ÚisdirÚdirnameÚmakedirsÚabspathÚshutilÚcopyÚ
isinstanceÚstrÚtimeÚstrptimeÚgmtimeÚgetctimeÚprintÚgetenvÚlowerr   r   ÚrangeÚ_fetch_fileÚIOErrorÚsleep)ÚfnameÚ	directoryÚforce_downloadÚautoÚ	_url_rootÚurlÚnfnameÚgiven_directoryÚdirsÚdirÚfilenameÚ	filename2ÚntimeÚftimeÚis                  r   Úget_remote_filerK       s{  € ð: J€IØ
Ñ
€CÜ�[Š[˜Ó€Fà€OØ×9¤;¨yÓ#9€IÜ‹?€DØ‡K�K��9ÔäˆÜ—7’7˜3Ó'ˆÜ�9Š9�X×ÓÞ!Þ" Ó'=Ü "§¡§¡¨_Ó E�IäŸ8š8¤B§J¢J¨yÓ$9×:Ñ:ÜŸš¤B§J¢J¬r¯zªz¸)Ó/DÓ$EÔFÜ—K’K Ô4Ø$Ò$Ø’Ü˜.¬#×.Ô.ÜŸš n°jÓA�ÜŸš¤B§K¢K°Ó$9Ó:�Ø“>Þ&¨?Ó+AÜ$&§G¡G§L¡L°Ó$I˜	ä!Ÿxšx¬¯
ª
°9Ó(=×>Ñ>ÜŸKšK¬¯
ª
´2·:²:¸iÓ3HÓ(IÔJÜŸš HÔ8Ø(Ò(Ø#’OäÐ;¸nÑLÔMÙñ5 ô: 
‡y‚yÐ&¨Ó+×1Ñ1Ó3Ð7KÓKÜ%ð*ó
ð 	
ö ÜÓ!Ð!ô �wŠw�yÓ)€HÜ�8Š8”B—J’J˜xÓ(×)Ñ)Ü
�Š”B—J’JœrŸzšz¨(Ó3Ó4Ô5ä	‡y‚yÐ)¨5×1Ñ1ä�q–ˆAð Ü˜CÔ*Ø’ñ ô ˜Ô&ØˆOä�CÔ"Øˆøô ó  Ü—
’
˜3—ð ús   ÍN	Î	 N-Î,N-c                 óð  • [        S[        R                  R                  U5      -  5        US-   nSnSn/ n[	        S5       Hï  n [        U SS9n[        UR                  S   R                  5       5      n	[        U	5      n
[        S	US
-   X
4-  5        [        US5      n[        X„US9  UR                  (       d  UR                  5         [        R                  " X15        USL a"  [         R"                  R%                  SU-  5         Ub%  UR                  (       d  UR                  5           g  g  g   [-        S[        R                  R                  U5      -  5      e! [&         a2  nUR)                  U5        [        S[+        U5      -  5         SnAOSnAff = f Ub'  UR                  (       d  UR                  5         GM…  GMˆ  GM‹  ! Ub#  UR                  (       d  UR                  5         f f f = f)a«  Load requested file, downloading it if needed or requested

Parameters
----------
url: string
    The url of file to be downloaded.
file_name: string
    Name, along with the path, of where downloaded file will be saved.
print_destination: bool, optional
    If true, destination of where file was saved will be printed after
    download finishes.
resume: bool, optional
    If true, try to resume partially downloaded files.
z?Imageio: %r was not found on your computer; downloading it now.z.partNr   é   g      @)ÚtimeoutúContent-LengthzTry %i. Download from %s (%s)r   Úwb)Úinitial_sizeTzFile saved as %s.
zError while fetching file: %s.zhUnable to download %r. Perhaps there is no internet connection? If there is, please report this problem.)r5   r(   r   Úbasenamer8   r	   ÚintÚheadersÚstripÚ_sizeof_fmtÚopenÚ_chunk_readÚclosedÚcloser-   ÚmoveÚsysÚstdoutÚwriteÚ	ExceptionÚappendr0   r:   )rA   Ú	file_nameÚprint_destinationÚtemp_file_nameÚ
local_filerQ   ÚerrorsÚtriesÚremote_fileÚ	file_sizeÚsize_strÚes               r   r9   r9   ƒ   sÐ  € ô$ 
ð	Ü "§¡× 0Ñ 0°Ó ;ñ	<ôð
  Ñ(€NØ€JØ€LØ€FÜ�q–ˆð	'ä! #¨sÑ3ˆKÜ˜K×/Ñ/Ð0@ÑA×GÑGÓIÓJˆIÜ" 9Ó-ˆHÜÐ1°U¸Q±YÀÐ4NÑNÔOä˜n¨dÓ3ˆJÜ˜¸lÒKà×$×$Ø× Ñ Ô"Ü�KŠK˜Ô2Ø  DÒ(Ü—
‘
× Ñ Ð!6¸Ñ!BÔCØð
 Ñ%Ø!×(×(Ø×$Ñ$Ö&ñ )ñ &ñ+ ô2 ðCä�g‰g×Ñ˜yÓ)ñ*ó
ð 	
øô ó 	=Ø�M‰M˜!ÔÜÐ2´S¸³VÑ;×<Ñ<ûð	=úà<àÑ%Ø!×(×(Ø×$Ñ$×&ò )ò &øˆzÑ%Ø!×(×(Ø×$Ñ$Õ&ð )ð &ús+   ÁCE Å 
FÅ*(FÆGÆFÆGÇ(G5c                 ó&  • Un[        U R                  S   R                  5       5      nXS-  n[        S5      nUR	                  SSU5         U R                  U5      nU[        U5      -  nU(       d  O[        XqU5        M5  UR                  S5        g)aÆ  Download a file chunk by chunk and show advancement

Can also be used when resuming downloads over http.

Parameters
----------
response: urllib.response.addinfourl
    Response to the download request in order to get file size.
local_file: file
    Hard disk file where data should be written.
chunk_size: integer, optional
    Size of downloaded chunks. Default: 8192
initial_size: int, optional
    If resuming, indicate the initial size of the file.
rO   ÚDownloadingr   ÚbytesÚDoneN)	rS   rT   rU   r   ÚstartÚreadÚlenÚ_chunk_writeÚfinish)Úresponserd   Ú
chunk_sizerQ   Úbytes_so_farÚ
total_sizeÚprogressÚchunks           r   rX   rX   ¾   sŽ   € ð&  €Lô �X×%Ñ%Ð&6Ñ7×=Ñ=Ó?Ó@€JØÑ€Jä& }Ó5€HØ‡N�N�2�w 
Ô+à
Ø—‘˜jÓ)ˆØœ˜E›
Ñ"ˆÞØÜ�U¨Ô1ñ ð ‡O�O�FÕr   c                 ó†   • UR                  U 5        UR                  [        U 5      5        [        R                  " S5        g)z1Write a chunk to file and update the progress barr   N)r^   Úincrease_progressrq   r1   r;   )ry   rd   rx   s      r   rr   rr   ã   s-   € à×Ñ�UÔØ×Ñœs 5›zÔ*Ü‡J‚Jˆq…Mr   c                 óè   • / SQn/ SQn U S:”  aZ  [        [        [        U S5      5      [        U5      S-
  5      n[	        U 5      SU-  -  nX   nX#   nSU-  nUR                  XE5      $ U S:X  a  S$ S$ )	z,Turn number of bytes into human-readable str)rm   ÚkBÚMBÚGBÚTBÚPB)r   r   r   r"   r"   r"   r   i   z{0:.%sf} {1}r   z0 bytesz1 byte)ÚminrS   r   rq   ÚfloatÚformat)ÚnumÚunitsÚdecimalsÚexponentÚquotientÚunitÚnum_decimalsÚformat_strings           r   rV   rV   ê   s‚   € â3€EÚ!€HØ"Ø
ˆQƒwÜ”sœ3˜s D›>Ó*¬C°«J¸©NÓ;ˆÜ˜“:  h¡Ñ.ˆØ‰ˆØÑ)ˆØ&¨Ñ5ˆØ×#Ñ# HÓ3Ð3Ø˜q›ˆ9Ð. hÐ.r   )NFT)T)i    r   )r   Úmathr   r(   r   r#   r\   r-   r1   r   r   r   r   r	   r:   r   r   rK   r9   rX   rr   rV   r   r   r   Ú<module>rŽ      sW   ðñ
 -å Û 	Ý Û 
Û Û ç (ß .ô	˜gô 	ô˜ô ô`ôF8
ôv"òJó/r   