+
    åûjþ.  ã                  ó    € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHt R.t]P                  ! ]4      tR
R R llt ! R	 R4      tR# )af  Download an HTTP(S) file into a cache directory and reuse it on later calls.

Which class to use:

- Any HTTP(S) file cached under a name the caller gives: :class:`CachedDownloader`.
- ONNX models, cached under a name derived from their ``hf://`` name or URL, and JSON configs, cached under their
  URL: :class:`~kornia.onnx.utils.ONNXLoader`, its subclass.
)ÚannotationsN)ÚOptional)Úkornia_config)ÚdownloadÚCachedDownloaderc               ó$   € V ^8„  d   QhRRRRRR/# )é   ÚnameÚstrÚlabelÚreturnz	list[str]© )Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\onnx\download.pyÚ__annotate__r   *   s!   € ÷ ñ  Cð °ð Àñ ó    c                óü   € V P                  \        P                  R4      P                  R4      p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        V RV : R24      hV# )aŽ  Split ``name``, a relative path inside a cache directory, into its components, separated by ``/`` or ``os.sep``.

Args:
    name: The relative path.
    label: What ``name`` is, for the error message.

Raises:
    ValueError: If ``name`` is absolute, has a drive (on Windows) or has an empty, ``.`` or ``..`` component, which
        would put the path outside the cache directory or name no file.
Ú/c              3  óš   "  € T FA  q\         P                  9   ;'       g#    \        P                  P	                  V4      V8g  x € KC  	  R # 5i©N)Ú_core_downloadÚ_NOT_A_FILE_NAMEÚosÚpathÚbasename)Ú.0Úcs   & r   Ú	<genexpr>Ú,_relative_path_components.<locals>.<genexpr>8   s;   é € Ð
`ÑU_ÐPQ”×/Ñ/Ñ/×KÐK´2·7±7×3CÑ3CÀAÓ3FÈ!Ñ3KÔKÓU_ùs
   ‚A +ATFzm must be a relative path inside the cache directory, without a drive or an empty, '.' or '..' component; got Ú.)Úreplacer   ÚsepÚsplitÚanyÚ
ValueError)r	   r   Ú
componentss   && r   Ú_relative_path_componentsr&   *   sq   € ð —‘œbŸf™f cÓ*×0Ñ0°Ó5€Jß
ƒsÑ
`ÑU_Ó
`‡s‡s‚sÑ
`ÑU_Ó
`×`Ò`ÜØˆgð Ø"™X Qð(ó
ð 	
ð Ðr   c                  ó€   € ] tR t^@tRt]RR R ll4       t]RRRRRRR/R	 R
 lll4       t]RRR/R R lll4       tRt	R# )r   a…  Download an HTTP(S) file into a cache directory under a caller-given name, once.

``path = CachedDownloader.download_to_cache(url, name, suffix=".onnx")`` returns ``<cache_dir>/<name>``, with
``suffix`` appended unless ``name`` already ends with it, and downloads ``url`` there if that file does not exist.
A cached file is returned as it is, without contacting the server, until ``force_download=True`` or its deletion.
``CachedDownloader.download(url, file_path)`` downloads to an explicit path by the same rule and returns ``None``.

See Also:
    - :class:`~kornia.onnx.utils.ONNXLoader`: its subclass, which derives the cache name from the URL or a
      model's ``hf://`` name, and loads the ONNX model or JSON config.
    - :func:`~kornia.core.download_file_from_url`: caches in torch's hub checkpoint directory, with fallback URLs,
      retries and a ``validate`` hook for a truncated file.

Nc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú
model_namer
   Ú	cache_dirúOptional[str]Úsuffixr   r   )r   s   "r   r   ÚCachedDownloader.__annotate__Q   s/   € ÷ "Dñ "D¨ð "D¸ð "DÈ}ð "DÐhkñ "Dr   c                óˆ  € \        V4      pVf   \        P                  p\        P                  P                  V4      pVR,          pVeR   VP                  V4      '       g;   V V 2p\        P                  P                  V4      V8w  d   \        RV: R24      h\        P                  P                  ! V.VRR OVN5!  # )ak  Construct the file path for the ONNX model based on the model name and cache directory.

Args:
    model_name: The name of the model or operator, typically in the format 'operators/model_name': a relative
        path whose components are separated by ``/`` (or ``os.sep``).
    cache_dir: The directory where the model should be cached.
        Defaults to None, which will use the default ``kornia.config.kornia_config.hub_cache_dir`` directory.
    suffix: Optional file suffix when the filename is the model name.

Returns:
    str: The full local path where the model should be stored or loaded from.

Raises:
    ValueError: If ``model_name`` is absolute, has a drive (on Windows) or has an empty, ``.`` or ``..``
        component, which would put the file outside ``cache_dir`` or name no file, or if ``suffix`` adds a
        directory or a drive to the file name.

NzAsuffix must not add a directory or a drive to the file name; got r   éÿÿÿÿ)
r&   r   Úhub_cache_dirr   r   Ú
expanduserÚendswithr   r$   Újoin)Úclsr)   r*   r,   r%   Ú	file_names   &&&&  r   Ú_get_file_pathÚCachedDownloader._get_file_pathP   s¶   € ô( /¨zÓ:ˆ
ð ÒÜ%×3Ñ3ˆIÜ—G‘G×&Ñ& yÓ1ˆ	ð ˜r•Nˆ	ØÒ i×&8Ñ&8¸×&@Ò&@Ø$˜+ f XÐ.ˆIä�w‰w×Ñ 	Ó*¨iÔ7Ü Ð#dÐekÑdnÐnoÐ!pÓqÐqä�w‰w�|Š|˜IÐC¨
°3°B¨ÐC¸ÓCÐCr   r*   r,   Úforce_downloadFc               ó4   € V ^8„  d   QhRRRRRRRRRRR	RR
R/# )r   Úurlr
   r	   r   Úboolr*   r+   r,   r8   r   r   )r   s   "r   r   r-   v   sY   € ÷ 4Pñ 4Pàð4Pð ð4Pð ð	4Pð !ð4Pð ð4Pð ð4Pð 
ñ4Pr   c               ó¼   € VP                  R4      '       d9   V P                  W$VR7      pV'       d   RR/M/ pV P                  ! W3RV/VB  V# \        RV 24      h)aŒ  Resolve a remote file into Kornia's local cache and download it when needed.

A file that is in the cache is used as it is, for as long as it exists: a model updated on the server is not
fetched again, and a cached file that is damaged, or was replaced by hand, stays so. Pass
``force_download=True`` to fetch the file again, or delete the cached file.

Args:
    url: HTTP or HTTPS URL of the file to cache.
    name: Logical model or operator name used to construct the cache
        path. Directory components in ``name``, separated by ``/``, are
        preserved under the cache directory.
    download: If ``True``, download the file when it is not already
        present in the cache. If ``False``, require the cached file to
        exist.
    cache_dir: The cache root. Defaults to ``None``, which uses
        ``kornia.config.kornia_config.hub_cache_dir``; ``""`` is the
        current working directory.
    suffix: Appended to the file name unless it already ends with it.
    force_download: If ``True``, fetch the file from ``url`` even when it is already cached, and replace the
        cached file with it. The old file is replaced only once the new one is complete, so a fetch that
        fails leaves it as it was. Needs ``download=True``. Defaults to ``False``.

Returns:
    Local filesystem path to the cached file.

Raises:
    ValueError: If ``url`` is not an HTTP or HTTPS URL, if ``name`` is absolute or has a drive or an empty,
        ``.`` or ``..`` component, if ``suffix`` adds a directory to the file name, if download is disabled
        and the file is missing, if ``force_download`` is ``True`` while ``download`` is ``False``, if the
        server answers with an HTTP error, or if ``KORNIA_DOWNLOAD_TIMEOUT`` is set to anything but a
        positive number of seconds.
    TimeoutError: If the server goes ``KORNIA_DOWNLOAD_TIMEOUT`` seconds without answering (see ``download``).
    urllib.error.URLError: If the server cannot be reached, or ``urllib.error.ContentTooShortError``
        if the body is shorter than its ``Content-Length`` (see ``download``).
    http.client.IncompleteRead: If a chunked body is cut mid-chunk (see ``download``).
)r,   r8   TÚdownload_if_not_existsz-URL must start with 'http:' or 'https:'. Got ©zhttp:zhttps:)Ú
startswithr6   r   r$   )	r4   r:   r	   r   r*   r,   r8   Ú	file_pathÚextras	   &&&&$$$  r   Údownload_to_cacheÚ"CachedDownloader.download_to_cacheu   sh   € ð^ �>‰>Ð-×.Ò.Ø×*Ñ*¨4À6Ð*ÓJˆIç0>Ð% tÑ,ÀBˆEØ�LŠL˜ÑRÀÐRÈEÒRØÐÜÐHÈÈÐNÓOÐOr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r:   r
   r@   r=   r;   r8   r   ÚNoner   )r   s   "r   r   r-   ­   sC   € ÷ >Hñ >Hàð>Hð ð>Hð !%ð	>Hð ð>Hð 
ñ>Hr   c               ó€  € \         P                  P                  V4      pV'       d   V'       g   \        R4      h\         P                  P	                  V4      '       d'   V'       g   \
        P                  RV RV R24       R# V'       g   \        RV R24      h\         P                  P                  V4      pV'       d   \         P                  ! VRR	7       VP                  R4      '       d8    \
        P                  R
V RV R24       \        P                  ! WRR7       R# \        R4      h  \        P                  P                   d   p\        RT R24      ThRp?i\        P                   dB   p\        P                  P!                  RTP"                   RTP$                   R2R4      ThRp?ii ; i)aº  Download an HTTP(S) file to ``file_path``, unless that file already exists.

Args:
    url: The HTTP(S) URL of the file to download.
    file_path: The local path where the downloaded file is saved; its directories are created. A path may
        start with ``~``.
    download_if_not_exists: If True, the file will be downloaded if it's not already downloaded.
    force_download: If True, download the file even when ``file_path`` exists, and replace it. The old file
        is replaced only once the new one is complete, so a download that fails leaves it as it was. Needs
        ``download_if_not_exists=True``.

Raises:
    ValueError: If the file is missing and ``download_if_not_exists`` is ``False``, if ``force_download`` is
        ``True`` while ``download_if_not_exists`` is ``False``, if ``url`` is not an HTTP or HTTPS URL, if
        the server answers with an HTTP error, or if ``KORNIA_DOWNLOAD_TIMEOUT`` is set to anything but a
        positive number of seconds.
    TimeoutError: If the server goes ``KORNIA_DOWNLOAD_TIMEOUT`` seconds (30 s when it is unset) without
        answering. An existing cached file is left unchanged.
    urllib.error.ContentTooShortError: If the body is shorter than its ``Content-Length``. An existing cached
        file is left unchanged.
    http.client.IncompleteRead: If a chunked body is cut mid-chunk. An existing cached file is left unchanged.
    urllib.error.URLError: If the server cannot be reached.

z_`force_download=True` needs `download=True`: it cannot fetch a file that may not be downloaded.z	Loading `z` from `z`.NÚ`z)` not found. You may set `download=True`.T)Úexist_okzDownloading `z` to `F)ÚprogresszError in resolving `zretrieval incomplete: got only z out of z bytesr   z'URL must start with 'http:' or 'https:'r>   )r   r   r1   r$   ÚexistsÚ_loggerÚinfoÚdirnameÚmakedirsr?   r   Ú_download_url_to_fileÚurllibÚerrorÚ	HTTPErrorÚ_TruncatedTransferÚContentTooShortErrorÚreceivedÚ	announced)r4   r:   r@   r=   r8   Ú	directoryÚexcs   &&&&$  r   r   ÚCachedDownloader.download¬   sj  € ôB —G‘G×&Ñ& yÓ1ˆ	ß×"8äØqóð ô �7‰7�>‰>˜)×$Ò$¯^Ü�L‰L˜9 S E¨°)°¸BÐ?Ô@Ùç%Ü˜q  Ð+TÐUÓVÐVä—G‘G—O‘O IÓ.ˆ	ßÜ�KŠK˜	¨DÕ1à�>‰>Ð-×.Ò.ð
Ü—‘˜}¨S¨E°¸	°{À"ÐEÔFÜ×4Ò4°SÈe×Tô ÐFÓGÐGøô —<‘<×)Ñ)ô JÜ Ð#7¸°u¸BÐ!?Ó@ÀcÐIûÜ!×4Ñ4ô ô —l‘l×7Ñ7Ø5°c·l±l°^À8ÈCÏMÉMÈ?ÐZ`ÐaÐcfóàðûðús*   Ã44D5 Ä5F=ÅE$Å$F=Å;F=Å<<F8Æ8F=r   r   )T)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úclassmethodr6   rB   r   Ú__static_attributes__r   r   r   r   r   @   sw   † ñð ö"Dó ð"DðH ñ4Pð $(ð4Pð !%ð4Pð  %÷4Pó ð4Pðl ñ>Hð  %÷>Hó ô>Hr   )r	   )r^   Ú
__future__r   Úloggingr   Úurllib.errorrP   Útypingr   Úkornia.configr   Úkornia.corer   r   Ú__all__Ú	getLoggerrZ   rK   r&   r   r   r   r   Ú<module>ri      sL   ðñ$õ #ã Û 	Û Ý å 'Ý 2àÐ
€à
×
Ò
˜HÓ
%€÷÷,kHó kHr   