§
    }ŠtjWì  ã            
       óB  — U d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d dlmZ d d	lmZmZ d d
lmZmZmZ d dlmZmZ d dlZd dlZd dlmZm Z m!Z! d dl"m#Z# d dl$m%Z% ddl&m'Z' ddl(m)Z)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@mAZA ddlBmCZC e G d„ d¦  «        ¦   «         ZDe G d„ deD¦  «        ¦   «         ZEe G d„ deD¦  «        ¦   «         ZF eGejH        ¦  «        ZIeeJd<    G d„ deI¦  «        ZK G d „ d!ejH        eK¬"¦  «        ZL G d#„ d$ejM        jN        ¦  «        ZO G d%„ d&ejM        jN        ¦  «        ZPd'eQd(eQfd)„ZRd*eQd(eQfd+„ZSd,eQd-eTdz  d(efd.„ZUd/eLd,eQd0eQd1eVd2eQf
d3„ZWd4„ ZX eL¦   «         ZYdS )5é    N)Údeque)ÚIterableÚIterator)Ú	ExitStack)Údeepcopy)Ú	dataclassÚfield)Údatetime)Úchain)ÚPathÚPurePosixPath)ÚAnyÚNoReturnÚUnion)ÚquoteÚunquote)Ú_DEFAULT_CALLBACKÚNoOpCallbackÚTqdmCallback)Úapply_config)Ú
isfilelikeé   )Ú	constants)ÚCommitOperationCopyÚCommitOperationDelete)ÚBucketNotFoundErrorÚEntryNotFoundErrorÚHfHubHTTPErrorÚRepositoryNotFoundErrorÚRevisionNotFoundError)Ú
hf_hub_urlÚhttp_get)ÚSPECIAL_REFS_REVISION_REGEXÚ
BucketFileÚBucketFolderÚHfApiÚLastCommitInfoÚRepoFileÚ
RepoFolder)ÚHFValidationErrorÚhf_raise_for_statusÚhttp_backoffÚhttp_stream_backoffÚparse_hf_uri)Úmd5c                   ó4   — e Zd ZU dZeed<   eed<   defd„ZdS )ÚHfFileSystemResolvedPathz_Top level Data structure containing information about a resolved Hugging Face file system path.ÚrootÚpathÚreturnc                 óJ   — | j         › d| j        › �                     d¦  «        S )Nú/)r2   r3   Úrstrip©Úselfs    ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/hf_file_system.pyÚ	unresolvez"HfFileSystemResolvedPath.unresolve+   s(   € Ø”)Ð)Ð)˜dœiÐ)Ð)×0Ò0°Ñ5Ô5Ð5ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r;   © r<   r:   r1   r1   $   sI   € € € € € € àiÐià
€I€I�IØ
€I€I�Ið6˜3ð 6ð 6ð 6ð 6ð 6ð 6r<   r1   c                   ó°   — e Zd ZU dZeed<   eed<   eed<   eed<    ed¬¦  «        Zeed<    ed¬¦  «        Zeed	<    ed
d¬¦  «        Z	ed
z  ed<   d„ Z
d
S )Ú"HfFileSystemResolvedRepositoryPathzLData structure containing information about a resolved path in a repository.Ú	repo_typeÚrepo_idÚrevisionÚpath_in_repoF©Úinitr2   r3   N)ÚdefaultÚreprÚ_raw_revisionc                 ó   — t           j                             | j        d¦  «        | j        z   }| j        r|› d| j        › �| _        n;| j        t           j        k    r|› dt          | j        ¦  «        › �| _        n|| _        | j
        | _        d S )NÚ ú@)r   ÚREPO_TYPES_URL_PREFIXESÚgetrF   rG   rN   r2   rH   ÚDEFAULT_REVISIONÚsafe_revisionrI   r3   )r9   Ú	repo_paths     r:   Ú__post_init__z0HfFileSystemResolvedRepositoryPath.__post_init__=   s�   € ÝÔ5×9Ò9¸$¼.È"ÑMÔMÐPTÔP\Ñ\ˆ	ØÔð 	"Ø$Ð;Ð; tÔ'9Ð;Ð;ˆDŒIˆIØŒ]�iÔ8Ò8Ð8Ø$ÐEÐE¥}°T´]Ñ'CÔ'CÐEÐEˆDŒIˆIà!ˆDŒIØÔ%ˆŒ	ˆ	ˆ	r<   )r=   r>   r?   r@   rA   rB   r	   r2   r3   rN   rW   rC   r<   r:   rE   rE   /   s±   € € € € € € àVÐVà€N€N�NØ€L€L�LØ€M€M�MØÐÐÑØ�˜5Ð!Ñ!Ô!€Dˆ#Ð!Ð!Ñ!Ø�˜5Ð!Ñ!Ô!€Dˆ#Ð!Ð!Ñ!ð !& ¨d¸Ð ?Ñ ?Ô ?€M�3˜‘:Ð?Ð?Ñ?ð&ð &ð &ð &ð &r<   rE   c                   óF   — e Zd ZU dZeed<    ed¬¦  «        Zeed<   d„ ZdS )ÚHfFileSystemResolvedBucketPathzHData structure containing information about a resolved path in a bucket.Ú	bucket_idFrJ   r2   c                 ó$   — d| j         z   | _        d S )Nzbuckets/)rZ   r2   r8   s    r:   rW   z,HfFileSystemResolvedBucketPath.__post_init__O   s   € Ø ¤Ñ/ˆŒ	ˆ	ˆ	r<   N)	r=   r>   r?   r@   rA   rB   r	   r2   rW   rC   r<   r:   rY   rY   H   sQ   € € € € € € àRÐRà€N€N�NØ�˜5Ð!Ñ!Ô!€Dˆ#Ð!Ð!Ñ!ð0ð 0ð 0ð 0ð 0r<   rY   Ú_cached_basec                   ó(   ‡ — e Zd ZdZˆ fd„Zd„ Zˆ xZS )Ú_Cachedaò  
    Metaclass for caching HfFileSystem instances according to the args.

    This creates an additional reference to the filesystem, which prevents the
    filesystem from being garbage collected when all *user* references go away.
    A call to the :meth:`AbstractFileSystem.clear_instance_cache` must *also*
    be made for a filesystem instance to be garbage collected.

    This is a slightly modified version of `fsspec.spec._Cached` to improve it.
    In particular in `_tokenize` the pid isn't taken into account for the
    `fs_token` used to identify cached instances. The `fs_token` logic is also
    robust to defaults values and the order of the args. Finally new instances
    reuse the states from sister instances in the main thread.
    c                 óH   •—  t          ¦   «         j        |i |¤Ž i | _        d S ©N)ÚsuperÚ__init__Ú_cache)ÚclsÚargsÚkwargsÚ	__class__s      €r:   rb   z_Cached.__init__g   s,   ø€ à�‰ŒÔ˜$Ð) &Ð)Ð)Ð)ð ˆŒ
ˆ
ˆ
r<   c                 ót  — t          | |¦  «        }|                     dd¦  «        } | j        | t          j        ¦   «         g|¢R i |¤Ž} | j        | t          j        ¦   «         j        g|¢R i |¤Ž}|s$| j        r|| j        v r|| _	        | j        |         S t          j        | g|¢R i |¤Ž}|sZ| j        rS|| j        v rJ| j        |                              ¦   «         }|                     ¦   «         D ]\  }}	t          |||	¦  «         Œ||_        ||_        ||_        | j        r|s|| _	        || j        |<   |S )NÚskip_instance_cacheF)r   ÚpopÚ	_tokenizeÚ	threadingÚ	get_identÚmain_threadÚidentÚcachablerc   Ú_latestÚtypeÚ__call__Ú_get_instance_stateÚitemsÚsetattrÚ
_fs_token_Ústorage_argsÚstorage_options)
rd   re   rf   ÚskipÚfs_tokenÚfs_token_main_threadÚobjÚinstance_stateÚattrÚstate_values
             r:   rs   z_Cached.__call__o   sƒ  € õ ˜c 6Ñ*Ô*ˆØ�zŠzÐ/°Ñ7Ô7ˆØ �3”= ¥iÔ&9Ñ&;Ô&;ÐM¸dÐMÐMÐMÀfÐMÐMˆØ,˜sœ}¨Sµ)Ô2GÑ2IÔ2IÔ2OÐaÐRVÐaÐaÐaÐZ`ÐaÐaÐØð 	˜œð 	¨°S´ZÐ)?Ð)?à"ˆCŒKØ”:˜hÔ'Ð'õ ”- Ð5 dÐ5Ð5Ð5¨fÐ5Ð5ˆCØð 4˜CœLð 4Ð-AÀSÄZÐ-OÐ-Oà!$¤Ð,@Ô!A×!UÒ!UÑ!WÔ!W�Ø)7×)=Ò)=Ñ)?Ô)?ð 4ð 4Ñ%�D˜+Ý˜C  {Ñ3Ô3Ð3Ð3Ø%ˆCŒNØ#ˆCÔØ"(ˆCÔØŒ|ð + Dð +Ø&�”Ø'*�”
˜8Ñ$ØˆJr<   )r=   r>   r?   r@   rb   rs   Ú__classcell__©rg   s   @r:   r^   r^   W   sQ   ø€ € € € € ðð ðð ð ð ð ðð ð ð ð ð ð r<   r^   c                   óô  ‡ — e Zd ZdZdZdZdddddœdedz  deez  dz  dedz  d	edz  fˆ fd
„Z	e
dedefd„¦   «         Zdedededz  deeedz  f         fd„Zdedeeedz  f         fd„Z	 d9dededz  deez  fd„Zd9dedz  ddfd„Z	 	 	 d:dedededz  dedz  ded         f
d„Zd9dededz  ddfd„Z	 	 	 d;dedededz  dedz  ddf
d„Z	 d<ded!ed"ededz  deeeeef         z           f
d#„Z	 	 	 	 	 d=deded"ededz  d	edz  dedz  fd$„Zded%ededeeez           fd&„Z dede!eeee         ee         f                  fˆ fd'„Z"d9dededz  dee         fˆ fd(„Z#	 	 	 	 	 d>dededz  d)ed!ed"ededz  dee         eeeeef         f         z  fd*„Z$d9d+ed,ededz  ddfd-„Z%dede&fd.„Z'd?ded"ededz  deeef         fd/„Z(d0„ Z)d1„ Z*d2„ Z+dedefd3„Z,e-dfd@ˆ fd4„Z.e/d5„ ¦   «         Z0d6„ Z1d7„ Z2d8„ Z3ˆ xZ4S )AÚHfFileSystemaz
  
    Access a remote Hugging Face Hub repository as if were a local file system.

    > [!WARNING]
    > [`HfFileSystem`] provides fsspec compatibility, which is useful for libraries that require it (e.g., reading
    >     Hugging Face datasets directly with `pandas`). However, it introduces additional overhead due to this compatibility
    >     layer. For better performance and reliability, it's recommended to use `HfApi` methods when possible.

    The file system supports paths for the `hf://` protocol, which follows those URL schemes:

    * Models, Datasets and Spaces repositories:

        ```
        hf://<repo-id>[@<revision>]/<path/in/repo>
        hf://datasets/<repo-id>[@<revision>]/<path/in/repo>
        hf://spaces/<repo-id>[@<revision>]/<path/in/repo>
        ```

    * Buckets (generic storage):

        ```
        hf://buckets/<bucket-id>/<path/in/bucket>
        ```

    Note: when using the [`HfFileSystem`] directly, passing the `hf://` protocol prefix is optional in paths.

    Args:
        endpoint (`str`, *optional*):
                Endpoint of the Hub. Defaults to <https://huggingface.co>.
        token (`bool` or `str`, *optional*):
            A valid user access token (string). Defaults to the locally saved
            token, which is the recommended method for authentication (see
            https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
            To disable authentication, pass `False`.
        block_size (`int`, *optional*):
            Block size for reading and writing files.
        expand_info (`bool`, *optional*):
            Whether to expand the information of the files.
        **storage_options (`dict`, *optional*):
            Additional options for the filesystem. See [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.__init__).

    Usage:

    ```python
    >>> from huggingface_hub import hffs

    >>> # List files
    >>> hffs.glob("my-username/my-model/*.bin")
    ['my-username/my-model/pytorch_model.bin']
    >>> hffs.ls("datasets/my-username/my-dataset", detail=False)
    ['datasets/my-username/my-dataset/.gitattributes', 'datasets/my-username/my-dataset/README.md', 'datasets/my-username/my-dataset/data.json']

    >>> # Read/write files
    >>> with hffs.open("my-username/my-model/pytorch_model.bin") as f:
    ...     data = f.read()
    >>> with hffs.open("my-username/my-model/pytorch_model.bin", "wb") as f:
    ...     f.write(data)
    ```

    Specify a token for authentication:
    ```python
    >>> from huggingface_hub import HfFileSystem
    >>> hffs = HfFileSystem(token=token)
    ```
    rP   ÚhfN)ÚendpointÚtokenÚ
block_sizeÚexpand_infor†   r‡   rˆ   r‰   c                óà   •—  t          ¦   «         j        |i |¤Ž |pt          j        | _        || _        t          ||¬¦  «        | _        || _        || _	        i | _
        i | _        i | _        d S )N)r†   r‡   )ra   rb   r   ÚENDPOINTr†   r‡   r&   Ú_apirˆ   r‰   Ú_repo_and_revision_exists_cacheÚ_bucket_exists_cacheÚdircache)r9   r†   r‡   rˆ   r‰   re   ry   rg   s          €r:   rb   zHfFileSystem.__init__Ò   s{   ø€ ð 	�‰ŒÔ˜$Ð2 /Ð2Ð2Ð2Ø Ð6¥IÔ$6ˆŒØˆŒ
Ý 8°5Ð9Ñ9Ô9ˆŒ	Ø$ˆŒØ&ˆÔð rtˆÔ,àNPˆÔ!ð :<ˆŒˆˆr<   Úthreading_identr4   c                 óB  ‡— ‰                      d¦  «        pt          j        ‰d<   ‰                      d¦  «        ‰d<   ˆfd„t          ‰¦  «        D ¦   «         Š| ||‰f}t	          t          |¦  «                             ¦   «         ¦  «        }|                     ¦   «         S )zDeterministic token for cachingr†   r‡   c                 ó"   •— i | ]}|‰|         “ŒS rC   rC   )Ú.0Úkeyrf   s     €r:   ú
<dictcomp>z*HfFileSystem._tokenize.<locals>.<dictcomp>ñ   s   ø€ Ð=Ð=Ð= s�#�v˜c”{Ð=Ð=Ð=r<   )rS   r   r‹   Úsortedr/   rA   ÚencodeÚ	hexdigest)rd   r�   re   rf   Útokenize_argsÚhs      `  r:   rk   zHfFileSystem._tokenizeë   s”   ø€ ð $ŸZšZ¨
Ñ3Ô3ÐIµyÔ7IˆˆzÑØ Ÿ*š* WÑ-Ô-ˆˆw‰Ø=Ð=Ð=Ð=­f°V©n¬nÐ=Ñ=Ô=ˆà˜o¨t°VÐ<ˆÝ•�MÑ"Ô"×)Ò)Ñ+Ô+Ñ,Ô,ˆØ�{Š{‰}Œ}Ðr<   rF   rG   rH   c                 ó–  — |||f| j         vr®	 | j                             |||t          j        ¬¦  «         d| j         |||f<   d| j         ||d f<   nj# t
          t          f$ r(}d|f| j         |||f<   d|f| j         ||d f<   Y d }~n6d }~wt          $ r&}d|f| j         |||f<   d| j         ||d f<   Y d }~nd }~ww xY w| j         |||f         S )N)rH   rF   Útimeout©TNF)r�   rŒ   Ú	repo_infor   ÚHF_HUB_ETAG_TIMEOUTr   r*   r    )r9   rF   rG   rH   Úes        r:   Ú_repo_and_revision_existz%HfFileSystem._repo_and_revision_exist÷   sT  € ð �w Ð)°Ô1UÐUÐUð^Ø”	×#Ò#Ø h¸)ÍYÔMjð $ñ ô ð ð Xb�Ô4°iÀÈ(Ð5SÑTØS]�Ô4°iÀÈ$Ð5OÑPÐPøõ ,Õ->Ð?ð \ð \ð \ØW\Ð^_ÐW_�Ô4°iÀÈ(Ð5SÑTØSXÐZ[ÐS[�Ô4°iÀÈ$Ð5OÑPÐPÐPÐPÐPÐPøøøøÝ(ð ^ð ^ð ^ØW\Ð^_ÐW_�Ô4°iÀÈ(Ð5SÑTØS]�Ô4°iÀÈ$Ð5OÑPÐPÐPÐPÐPÐPøøøøð^øøøð Ô3°YÀÈÐ4RÔSÐSs#   Ž(A ÁB8Á"BÂB8ÂB3Â3B8rZ   c                 óÀ   — || j         vrI	 | j                             |¦  «         d| j         |<   n## t          $ r}d|f| j         |<   Y d }~nd }~ww xY w| j         |         S )Nr�   F)rŽ   rŒ   Úbucket_infor   )r9   rZ   r    s      r:   Ú_bucket_existszHfFileSystem._bucket_exists
  s”   € Ø˜DÔ5Ð5Ð5ðBØ”	×%Ò% iÑ0Ô0Ð0ð 8B�Ô)¨)Ñ4Ð4øõ 'ð @ð @ð @Ø7<¸a°x�Ô)¨)Ñ4Ð4Ð4Ð4Ð4Ð4øøøøð@øøøð Ô(¨Ô3Ð3s   ‹0 °
AºAÁAr3   c                 ó´  — |                       |¦  «        }|st          d¦  «        ‚|                     d¦  «        dk    rt          d|› d�¦  «        ‚t	          t
          j        › |› �¦  «        }|j        rJ|                      |j	        ¦  «        \  }}|st          ||¦  «         t          |j	        |j        ¬¦  «        S |��|j        �ÿ|j        |k    rô|                     d¦  «        d         t
          j        v r|                     dd¦  «        d         n|}|                     d	d¦  «        \  }}d|v r|                     dd¦  «        n|d
f\  }	}
t!          |	¦  «        }||k    rt          d|› d|› d�¦  «        ‚|                      |j        ||¦  «        \  }}|st          ||¦  «         t'          |j        |||
|	¬¦  «        S |j        �	|€|j        }|                      |j        |j	        |¦  «        \  }}|st          ||¦  «         d}d	|v r‘|j        �Š|                     d¦  «        d         t
          j        v r|                     dd¦  «        d         n|}|                     d	d¦  «        d         }|j        r |dt)          |j        ¦  «        dz    …         n|}|�|nt
          j        }t'          |j        |j	        ||j        |¬¦  «        S )a€  
        Resolve a Hugging Face file system path into its components.

        Args:
            path (`str`):
                Path to resolve.
            revision (`str`, *optional*):
                The revision of the repo to resolve. Defaults to the revision specified in the path.

        Returns:
            [`HfFileSystemResolvedPath`]: Resolved path information containing `repo_type`, `repo_id`, `revision` and `path_in_repo`.

        Raises:
            `ValueError`:
                If path contains conflicting revision information.
            `NotImplementedError`:
                If trying to list repositories.
        z<Access to buckets and repositories lists is not implemented.r6   r   z-Repository id must be 'namespace/name', got 'z<'. Single-segment ids (e.g. 'gpt2') are no longer supported.)rZ   r3   Nr   rQ   rP   zRevision specified in path ("z ") and in `revision` argument ("z") are not the same.)rN   )Ú_strip_protocolÚNotImplementedErrorÚcountÚ
ValueErrorr.   r   ÚHF_PROTOCOLÚ	is_bucketr¤   ÚidÚ_raise_file_not_foundrY   rI   rH   ÚsplitÚHF_URI_TYPE_PREFIXESr   r¡   rr   rE   ÚlenrT   )r9   r3   rH   ÚparsedÚbucket_existsÚerrÚpath_without_typerG   Úafter_atÚrevision_in_pathrI   Úrevision_in_path_decodedÚrepo_and_revision_existÚraw_revisionÚraw_after_ats                  r:   Úresolve_pathzHfFileSystem.resolve_path  se  € ð* ×#Ò# DÑ)Ô)ˆØð 	fÝ%Ð&dÑeÔeÐeØ�:Š:�c‰?Œ?˜aÒÐÝð CÀð  Cð  Cð  Cñô ð õ ¥Ô!6Ð>¸Ð>Ð>Ñ?Ô?ˆð Ôð 	aØ!%×!4Ò!4°V´YÑ!?Ô!?ÑˆM˜3Ø ð 1Ý% d¨CÑ0Ô0Ð0Ý1¸F¼IÈFÔL_Ð`Ñ`Ô`Ð`ð Ñ F¤OÐ$?ÀFÄOÐW_ÒD_ÐD_ð
 :>¿ºÀC¹¼ÈÔ9KÍyÔOmÐ9mÐ9m §
¢
¨3°Ñ 2Ô 2°1Ô 5Ð 5ÐswÐØ 1× 7Ò 7¸¸QÑ ?Ô ?ÑˆG�XØGJÈhÀÀ¨X¯^ª^¸CÀÑ-CÔ-CÐ-CÐ]eÐgiÐ\jÑ*Ð˜lÝ'.Ð/?Ñ'@Ô'@Ð$Ø'¨8Ò3Ð3Ý ð MÐ4Lð  Mð  MÐnvð  Mð  Mð  Mñô ð ð ,0×+HÒ+HÈÌÐV]Ð_gÑ+hÔ+hÑ(Ð# SØ*ð 1Ý% d¨CÑ0Ô0Ð0Ý5Ø”˜W h°ÐL\ðñ ô ð ð Œ?Ð&¨8Ð+;Ø”ˆHà'+×'DÒ'DÀVÄ[ÐRXÔR[Ð]eÑ'fÔ'fÑ$Ð Ø&ð 	-Ý! $¨Ñ,Ô,Ð,ð $(ˆØ�$ˆ;ˆ;˜6œ?Ð6Ø9=¿ºÀC¹¼ÈÔ9KÍyÔOmÐ9mÐ9m §
¢
¨3°Ñ 2Ô 2°1Ô 5Ð 5ÐswÐØ,×2Ò2°3¸Ñ:Ô:¸1Ô=ˆLØNTÔNaÐs˜<Ð(I­C°Ô0CÑ,DÔ,DÀqÑ,HÐ*IÐ(IÔJÐJÐgsˆLà'Ð3�8�8½Ô9SˆÝ1ØŒK˜œ H¨fÔ.AÐQ]ð
ñ 
ô 
ð 	
r<   c                 óV  — |s4| j                              ¦   «          | j                             ¦   «          dS |                      |¦  «        }|                     ¦   «         }|r2| j                              |d¦  «         |                      |¦  «        }|°2|j        sŽt          |t          ¦  «        rW| j                             |j
        |j        dfd¦  «         | j                             |j
        |j        |j        fd¦  «         dS | j                             |j        d¦  «         dS dS )ac  
        Clear the cache for a given path.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.invalidate_cache).

        Args:
            path (`str`, *optional*):
                Path to clear from cache. If not provided, clear the entire cache.

        N)r�   Úclearr�   r»   r;   rj   Ú_parentr3   Ú
isinstancerE   rF   rG   rH   rŽ   rZ   )r9   r3   Úresolved_paths      r:   Úinvalidate_cachezHfFileSystem.invalidate_cachec  sX  € ð ð 	QØŒM×ÒÑ!Ô!Ð!ØÔ0×6Ò6Ñ8Ô8Ð8Ð8Ð8à ×-Ò-¨dÑ3Ô3ˆMØ ×*Ò*Ñ,Ô,ˆDØð *Ø”×!Ò! $¨Ñ-Ô-Ð-Ø—|’| DÑ)Ô)�ð ð *ð
 !Ô%ð 	QÝ˜mÕ-OÑPÔPð QØÔ8×<Ò<Ø&Ô0°-Ô2GÈÐNÐPTñô ð ð Ô8×<Ò<Ø&Ô0°-Ô2GÈÔI_Ð`Ðbfñô ð ð ð ð Ô-×1Ò1°-Ô2IÈ4ÑPÔPÐPÐPÐPð	Qð 	Qr<   ÚrbÚmode)ÚHfFileSystemFileÚHfFileSystemStreamFilec                 óœ   — |�|n| j         }|�||d<   d|v rt          d¦  «        ‚|dk    rt          | |f||dœ|¤ŽS t          | |f||dœ|¤ŽS )Nrˆ   Úaz/Appending to remote files is not yet supported.r   )rÃ   rH   )rˆ   r§   rÅ   rÄ   )r9   r3   rÃ   rˆ   rH   rf   s         r:   Ú_openzHfFileSystem._open„  s…   € ð $.Ð#9�Z�Z¸t¼ˆ
ØÐ!Ø#-ˆF�<Ñ Ø�$ˆ;ˆ;Ý%Ð&WÑXÔXÐXØ˜Š?ˆ?Ý)¨$°Ð]¸4È(Ð]Ð]ÐV\Ð]Ð]Ð]å# D¨$ÐW°TÀHÐWÐWÐPVÐWÐWÐWr<   c                 ó¾  — |                       ||¬¦  «        }t          |t          ¦  «        r(| j                             |j        |j        g¬¦  «         n`| j                             |j        |j	        | j
        |j        |j        |                     d¦  «        |                     d¦  «        ¬¦  «         |                      |                     ¦   «         ¬¦  «         d S )N©rH   ©ÚdeleteÚcommit_messageÚcommit_description)rI   rG   r‡   rF   rH   rÍ   rÎ   ©r3   )r»   r¿   rY   rŒ   Úbatch_bucket_filesrZ   r3   Údelete_filerI   rG   r‡   rF   rH   rS   rÁ   r;   )r9   r3   rH   rf   rÀ   s        r:   Ú_rmzHfFileSystem._rm–  sÛ   € Ø×)Ò)¨$¸Ð)ÑBÔBˆÝ�mÕ%CÑDÔDð 	ØŒI×(Ò(¨Ô)@È-ÔJ\ÐI]Ð(Ñ^Ô^Ð^Ð^àŒI×!Ò!Ø*Ô7Ø%Ô-Ø”jØ'Ô1Ø&Ô/Ø%ŸzšzÐ*:Ñ;Ô;Ø#)§:¢:Ð.BÑ#CÔ#Cð "ñ ô ð ð 	×Ò =×#:Ò#:Ñ#<Ô#<ÐÑ=Ô=Ð=Ð=Ð=r<   FÚ	recursiveÚmaxdepthc                 óf  ‡ — ‰                       ||¬¦  «        }‰                      ||||¬¦  «        }t          |t          ¦  «        r0ˆ fd„|D ¦   «         }‰ j                             |j        |¬¦  «         n’ˆ fd„|D ¦   «         }	d„ |	D ¦   «         }
d|› d�}||rd	nd
z  }||�d|› d�nd
z  }‰ j                             |j        |j	        ‰ j
        |
|j        |                     d|¦  «        |                     d¦  «        ¬¦  «         ‰                      |                     ¦   «         ¬¦  «         dS )aÔ  
        Delete files from a repository.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.rm).

        > [!WARNING]
        > Note: When possible, use `HfApi.delete_file()` for better performance.

        Args:
            path (`str`):
                Path to delete.
            recursive (`bool`, *optional*):
                If True, delete directory and all its contents. Defaults to False.
            maxdepth (`int`, *optional*):
                Maximum number of subdirectories to visit when deleting recursively.
            revision (`str`, *optional*):
                The git revision to delete from.

        rÊ   )rÓ   rÔ   rH   c                 ón   •— g | ]1}‰                      |¦  «        °‰                     |¦  «        j        ‘Œ2S rC   ©Úisdirr»   r3   ©r“   r3   r9   s     €r:   ú
<listcomp>z#HfFileSystem.rm.<locals>.<listcomp>Ä  s<   ø€ Ð]Ð]Ð]°tÈDÏJÊJÐW[ÑL\ÔL\Ð]�d×'Ò'¨Ñ-Ô-Ô2Ð]Ð]Ð]r<   rË   c                 ón   •— g | ]1}‰                      |¦  «        °‰                     |¦  «        j        ‘Œ2S rC   r×   rÙ   s     €r:   rÚ   z#HfFileSystem.rm.<locals>.<listcomp>Ç  s?   ø€ ÐdÐdÐd¸dÐSW×S]ÒS]Ð^bÑScÔScÐd˜T×.Ò.¨tÑ4Ô4Ô9ÐdÐdÐdr<   c                 ó.   — g | ]}t          |¬ ¦  «        ‘ŒS ))rI   )r   )r“   rI   s     r:   rÚ   z#HfFileSystem.rm.<locals>.<listcomp>È  s$   € ÐmÐmÐmÈ|Õ/¸\ÐJÑJÔJÐmÐmÐmr<   zDelete ú zrecursively rP   Nzup to depth rÍ   rÎ   )rG   rF   r‡   Ú
operationsrH   rÍ   rÎ   rÏ   )r»   Úexpand_pathr¿   rY   rŒ   rÐ   rZ   Úcreate_commitrG   rF   r‡   rH   rS   rÁ   r;   )r9   r3   rÓ   rÔ   rH   rf   rÀ   ÚpathsrÌ   Úpaths_in_reporÞ   rÍ   s   `           r:   ÚrmzHfFileSystem.rm¦  s~  ø€ ð6 ×)Ò)¨$¸Ð)ÑBÔBˆØ× Ò  °ÀXÐX`Ð ÑaÔaˆÝ�mÕ%CÑDÔDð 	Ø]Ð]Ð]Ð]¸uÐ]Ñ]Ô]ˆFØŒI×(Ò(¨Ô)@ÈÐ(ÑPÔPÐPÐPàdÐdÐdÐdÀeÐdÑdÔdˆMØmÐmÐ_lÐmÑmÔmˆJØ. tÐ.Ð.Ð.ˆNØ°	ÐA˜n˜n¸rÑAˆNØ¸HÐ<PÐ8¨XÐ8Ð8Ð8Ð8ÐVXÑXˆNàŒI×#Ò#Ø%Ô-Ø'Ô1Ø”jØ%Ø&Ô/Ø%ŸzšzÐ*:¸NÑKÔKØ#)§:¢:Ð.BÑ#CÔ#Cð $ñ ô ð ð 	×Ò =×#:Ò#:Ñ#<Ô#<ÐÑ=Ô=Ð=Ð=Ð=r<   TÚdetailÚrefreshc                 óÀ  ‡— |                       ‰|¬¦  «        }|                     ¦   «         Š	  | j        ‰f||dœ|¤Ž}n�# t          $ rƒ |j        st          ‰d¦  «         	  | j        |                      ‰¦  «        f||dœ|¤Ž}n# t          $ r g }Y nw xY wˆfd„|D ¦   «         }t          |¦  «        dk    rt          ‰d¦  «         Y nw xY w|r|nd„ |D ¦   «         S )a×  
        List the contents of a directory.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.ls).

        > [!WARNING]
        > Note: When possible, use `HfApi.list_repo_tree()` for better performance.

        Args:
            path (`str`):
                Path to the directory.
            detail (`bool`, *optional*):
                If True, returns a list of dictionaries containing file information. If False,
                returns a list of file paths. Defaults to True.
            refresh (`bool`, *optional*):
                If True, bypass the cache and fetch the latest data. Defaults to False.
            revision (`str`, *optional*):
                The git revision to list from.

        Returns:
            `list[Union[str, dict[str, Any]]]`: List of file paths (if detail=False) or list of file information
            dictionaries (if detail=True).
        rÊ   )rå   rH   Nc                 ó,   •— g | ]}|d          ‰k    ¯|‘ŒS ©ÚnamerC   ©r“   Úor3   s     €r:   rÚ   z#HfFileSystem.ls.<locals>.<listcomp>þ  s'   ø€ Ð7Ð7Ð7˜ Q v¤Y°$Ò%6Ð%6�1Ð%6Ð%6Ð%6r<   r   c                 ó   — g | ]
}|d          ‘ŒS rè   rC   ©r“   rë   s     r:   rÚ   z#HfFileSystem.ls.<locals>.<listcomp>  s   € Ð":Ð":Ð":° 1 V¤9Ð":Ð":Ð":r<   )r»   r;   Ú_ls_treer   r3   r­   r¾   r°   )r9   r3   rä   rå   rH   rf   rÀ   Úouts    `      r:   ÚlszHfFileSystem.lsØ  s>  ø€ ð4 ×)Ò)¨$¸Ð)ÑBÔBˆØ×&Ò&Ñ(Ô(ˆð	2Ø�$”- ÐS¨gÀÐSÐSÈFÐSÐSˆCˆCøÝ!ð 
	2ð 
	2ð 
	2à Ô%ð 2Ý% d¨DÑ1Ô1Ð1ðØ#�d”m D§L¢L°Ñ$6Ô$6ÐeÀÐRZÐeÐeÐ^dÐeÐe��øÝ%ð ð ð Ø���ðøøøà7Ð7Ð7Ð7˜cÐ7Ñ7Ô7ˆCÝ�3‰xŒx˜1Š}ˆ}Ý% d¨DÑ1Ô1Ð1øøð
	2øøøð Ð:ˆsˆsÐ":Ð":°cÐ":Ñ":Ô":Ð:s5   ®A  Á !CÁ"$BÂCÂBÂCÂBÂ4CÃCc           
      óÞ  ‡ ‡‡— |�|n‰ j         �‰ j         nd}‰                      ||¬¦  «        }|                     ¦   «         }|j        }|r|nd}g }	|‰ j        v �r[|�sX‰ j        |         }
|	                     |
¦  «         g }|r´dŠt          ˆfd„|
D ¦   «         ¦  «        }|r•|                     ¦   «         \  Š}|�‰|k    rt|d         ‰ j        vr|                     |d         ¦  «         nI‰ j        |d                  }
|	                     |
¦  «         |                     ˆfd„|
D ¦   «         ¦  «         |°•g }|r#t          |t          ¦  «        rˆ fd„|	D ¦   «         }|r|s|�rN|�rKt          j                             ||z   ¦  «        }|                     d	¦  «        s||k    s|t          ||¦  «        v r|                     d	¦  «        n‰                      |¦  «        Š|�/‰t%          |¦  «        d …                              d	¦  «        }||z  }ˆfd
„|	D ¦   «         }	t)          ‰ j        ¦  «        D ]5}|                     ‰d	z   ¦  «        r‰ j                             |d ¦  «         Œ6‰ j                             ‰d ¦  «         |	                     ‰                      ‰|d|||¬¦  «        ¦  «         �n¶t          |t0          ¦  «        r#‰                      |j        |j        |¬¦  «        }n4‰ j                             |j        |j        |||j        |j        ¬¦  «        }|D �]F}|d	z   |j        z   }t          |t@          ¦  «        r*||j!        d|j"        |j#        |j$        |j%        |j&        dœ}ngt          |tN          ¦  «        r||j!        d|j$        |j(        |j)        dœ}n4t          |tT          ¦  «        r|dd|j+        |j%        dœ}n|dd|j)        dœ}‰                      |d         ¦  «        }‰ j         ,                    |g ¦  «                             |¦  «         |t%          |¦  «        d …                              d	¦  «        Š|�‰|k    r|	                     |¦  «         �ŒH|	S )NFrÊ   r   é   c                 ó0   •— g | ]}|d          dk    ¯‰|f‘ŒS ©rr   Ú	directoryrC   ©r“   Ú	path_infoÚdepths     €r:   rÚ   z)HfFileSystem._ls_tree.<locals>.<listcomp>  s/   ø€ ÐoÐoÐo¨IÈiÐX^ÔN_ÐcnÒNnÐNn�e˜YÐ'ÐNnÐNnÐNnr<   ré   c                 ó6   •— g | ]}|d          dk    ¯‰dz   |f‘ŒS )rr   rõ   r   rC   rö   s     €r:   rÚ   z)HfFileSystem._ls_tree.<locals>.<listcomp>)  s<   ø€ ð !"ð !"ð !"à(1Ø'0°Ô'8¸KÒ'GÐ'Gð &+¨Q¡Y°	Ð$:à'GÐ'GÐ'Gr<   c                 óV   •— g | ]%}|d          ­
‰                      |d         ¦  «        ‘Œ&S )Úlast_commitNré   )r¾   )r“   rë   r9   s     €r:   rÚ   z)HfFileSystem._ls_tree.<locals>.<listcomp>3  s3   ø€ Ð$fÐ$fÐ$fÀÈQÈ}ÔM]ÐMe T§\¢\°!°F´)Ñ%<Ô%<ÐMeÐMeÐMer<   r6   c                 óP   •— g | ]"}|d                                ‰dz   ¦  «        ° |‘Œ#S )ré   r6   )Ú
startswith)r“   rë   Úcommon_paths     €r:   rÚ   z)HfFileSystem._ls_tree.<locals>.<listcomp>D  s6   ø€ ÐUÐUÐU˜Q¨Q¨v¬Y×-AÒ-AÀ+ÐPSÑBSÑ-TÔ-TÐU�qÐUÐUÐUr<   T)rÓ   rå   rH   r‰   rÔ   )ÚprefixrÓ   )rÓ   ÚexpandrH   rF   Úfile©ré   Úsizerr   Úblob_idÚlfsÚxet_hashrû   Úsecurity)ré   r  rr   r  ÚmtimeÚuploaded_atr   rõ   ©ré   r  rr   Útree_idrû   )ré   r  rr   r	  )-r‰   r»   r;   r2   r�   Úextendr   ÚpopleftÚappendr¿   rE   Úosr3   ÚcommonprefixÚendswithr   r7   r¾   r°   r¨   Úlistrý   rj   rî   rY   Ú_list_bucket_tree_with_foldersrZ   rŒ   Úlist_repo_treerG   rH   rF   r(   r  r  r  r  rû   r  r$   r  r	  r)   r  Ú
setdefault)r9   r3   rÓ   rå   rH   r‰   rÔ   rÀ   Ú	root_pathrï   Úcached_path_infosÚdirs_not_in_dircacheÚdirs_to_visitÚdir_infoÚdirs_not_expandedÚcommon_prefixÚcommon_path_depthÚcached_pathÚtreer÷   Ú
cache_pathÚcache_path_infoÚparent_pathrþ   rø   s   `                      @@r:   rî   zHfFileSystem._ls_tree  sz  øøø€ ð 'Ð2ˆKˆKÈTÔM]ÐMi¸Ô9IÐ9IÐotð 	ð ×)Ò)¨$¸Ð)ÑBÔBˆØ×&Ò&Ñ(Ô(ˆØ!Ô&ˆ	Ø(Ð/�8�8¨aˆàˆØ�4”=Ð Ñ ¨Ñ Ø $¤¨dÔ 3ÐØ�JŠJÐ(Ñ)Ô)Ð)Ø#%Ð Øð ð �Ý %ØoÐoÐoÐoÐ9JÐoÑoÔoñ!ô !�ð $ð Ø&3×&;Ò&;Ñ&=Ô&=‘O�E˜8ØÐ'¨5°HÒ+<Ð+<Ø# FÔ+°4´=Ð@Ð@Ø0×7Ò7¸ÀÔ8HÑIÔIÐIÐIà04´¸hÀvÔ>NÔ0OÐ-ØŸJšJÐ'8Ñ9Ô9Ð9Ø)×0Ò0ð!"ð !"ð !"ð !"à5Fð!"ñ !"ô !"ñô ð ð $ð ð  !#ÐØð g�z¨-Õ9[Ñ\Ô\ð gà$fÐ$fÐ$fÐ$fÀcÐ$fÑ$fÔ$fÐ!àð Ð2ð ¸ñ ÐHYñ õ !#¤× 4Ò 4Ð5IÐL]Ñ5]Ñ ^Ô ^�ð %×-Ò-¨cÑ2Ô2ð5à$¨	Ò1Ð1Ø$­Ð.BÐDUÑ(VÔ(VÐVÐVð "×(Ò(¨Ñ-Ô-Ð-ð Ÿš mÑ4Ô4ð ð Ð'Ø(3µC¸±I´I°K°KÔ(@×(FÒ(FÀsÑ(KÔ(KÐ%ØÐ 1Ñ1�HØUÐUÐUÐU #ÐUÑUÔU�Ý#'¨¬Ñ#6Ô#6ð =ð =�KØ"×-Ò-¨k¸CÑ.?Ñ@Ô@ð =Øœ×)Ò)¨+°tÑ<Ô<Ð<øØ”×!Ò! +¨tÑ4Ô4Ð4Ø—
’
Ø—M’MØ#Ø"+Ø $Ø!)Ø$/Ø!)ð "ñ ô ñ	ô 	ð 	ùõ ˜-Õ)GÑHÔHð Ø×:Ò:Ø!Ô+Ø(Ô-Ø'ð ;ñ ô ��ð ”y×/Ò/Ø!Ô)Ø!Ô&Ø'Ø&Ø*Ô3Ø+Ô5ð 0ñ ô �ð "ð )0ñ )0�	Ø&¨™_¨y¬~Ñ=�
Ý˜i­Ñ2Ô2ð "à *Ø )¤Ø &Ø#,Ô#4Ø(œ}Ø$-Ô$6Ø'0Ô'<Ø$-Ô$6ð	'ð 	'�O�Oõ   	­:Ñ6Ô6ð à *Ø )¤Ø &Ø$-Ô$6Ø!*¤Ø'0Ô'<ð'ð '�O�Oõ   	­:Ñ6Ô6ð à *Ø !Ø +Ø#,Ô#4Ø'0Ô'<ð'ð '�O�Oð !+Ø !Ø +Ø'0Ô'<ð	'ð '�Oð #Ÿlšl¨?¸6Ô+BÑCÔC�Ø”×(Ò(¨°bÑ9Ô9×@Ò@ÀÑQÔQÐQØ"¥3 t¡9¤9 ; ;Ô/×5Ò5°cÑ:Ô:�ØÐ# u°Ò'8Ð'8Ø—J’J˜Ñ/Ô/Ð/ùØˆ
r<   rÿ   c                 ó\  — | j                              |||¬¦  «        }i }|rd|                     d¦  «        z   nd}g }|D ]Ó}|                     |¦  «         |sŒt	          t          |j        ¦  «        j        ¦  «        d| dz
  …         D ]†}	t          dt          |	¦  «        |j
        ¬¦  «        }
|
j        |vr |                     |
¦  «         |
||
j        <   ŒO|
j
        �0||
j                 }|j
        �|j
        |
j
        k     r|
j
        |_
        Œ‡ŒÔ|st          d|› d	|› d
�¦  «        ‚|S )z<Same as `HfApi.list_bucket_tree` but always includes folders)rÓ   r   r6   r   Nrõ   )rr   r3   r	  zFile not found in bucket 'z': 'ú')rŒ   Úlist_bucket_treer¨   r  r  r   r3   Úparentsr%   rA   r	  r   )r9   rZ   rÿ   rÓ   Úbucket_filesÚbucket_foldersÚ	min_depthrï   Úbucket_entryÚparent_bucket_folder_strÚparent_bucket_folderÚbucket_folders               r:   r  z+HfFileSystem._list_bucket_tree_with_folders�  s�  € ð ”y×1Ò1°)¸VÈyÐ1ÑYÔYˆØ24ˆØ-3Ð:�A˜Ÿš SÑ)Ô)Ñ)Ð)¸ˆ	Ø/1ˆà(ð 	Uð 	UˆLØ�JŠJ�|Ñ$Ô$Ð$ð ð Øõ -1µ¸|Ô?PÑ1QÔ1QÔ1YÑ,ZÔ,ZÐ[kÐ^gÐ]gÐjkÑ]kÐ[kÔ,lð Uð UÐ(Ý'3Ø$­3Ð/GÑ+HÔ+HÐVbÔVnð(ñ (ô (Ð$ð
 (Ô,°NÐBÐBØ—J’JÐ3Ñ4Ô4Ð4Ø@T�NÐ#7Ô#<Ñ=Øð (Ô3Ð?Ø$2Ð3GÔ3LÔ$M�MØ$Ô0Ð8Ø%Ô1Ð4HÔ4TÒTÐTà4HÔ4T˜Ô1øð#Uð& ð 	\Ý$Ð%ZÀ)Ð%ZÐ%ZÐQWÐ%ZÐ%ZÐ%ZÑ[Ô[Ð[Øˆ
r<   c              /   óÊ   •K  — |                       ||                     d¦  «        ¬¦  «                             ¦   «         } t          ¦   «         j        |g|¢R i |¤ŽE d{V —† dS )aÁ  
        Return all files below the given path.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.walk).

        Args:
            path (`str`):
                Root path to list files from.

        Returns:
            `Iterator[tuple[str, list[str], list[str]]]`: An iterator of (path, list of directory names, list of file names) tuples.
        rH   rÊ   N)r»   rS   r;   ra   Úwalk)r9   r3   re   rf   rg   s       €r:   r/  zHfFileSystem.walk¸  sw   øè è € ð × Ò  °·
²
¸:Ñ0FÔ0FÐ ÑGÔG×QÒQÑSÔSˆØ•5‘7”7”< Ð6 tÐ6Ð6Ð6¨vÐ6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6r<   c                 ó´   •— |                       ||                     d¦  «        ¬¦  «                             ¦   «         } t          ¦   «         j        |fd|i|¤ŽS )aã  
        Find files by glob-matching.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.glob).

        Args:
            path (`str`):
                Path pattern to match.
            maxdepth (`int`, *optional*):
                Maximum depth to descend into directories. By default, no limit.

        Returns:
            `list[str]`: List of paths matching the pattern.
        rH   rÊ   rÔ   )r»   rS   r;   ra   Úglob)r9   r3   rÔ   rf   rg   s       €r:   r1  zHfFileSystem.globÈ  sX   ø€ ð × Ò  °·
²
¸:Ñ0FÔ0FÐ ÑGÔG×QÒQÑSÔSˆØ�u‰wŒwŒ|˜DÐ>Ð>¨8Ð>°vÐ>Ð>Ð>r<   Úwithdirsc                 óö  ‡— |�|dk     rt          d¦  «        ‚|                      ||¬¦  «        }|                     ¦   «         }	  | j        |fd||dœ|¤ŽŠ|sd„ ‰D ¦   «         Šn" | j        |fi |¤Ž}	|	d         d	k    r|	g‰z   n‰Šd
„ ‰D ¦   «         ŠnE# t
          $ r8 	  | j        |fd|i|¤Žd         dk    r|i iŠni Šn# t          $ r i ŠY nw xY wY nw xY wt          ‰¦  «        }
|s|
S ˆfd„|
D ¦   «         S )aÕ  
        List all files below path.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.find).

        Args:
            path (`str`):
                Root path to list files from.
            maxdepth (`int`, *optional*):
                Maximum depth to descend into subdirectories.
            withdirs (`bool`, *optional*):
                Include directory paths in the output. Defaults to False.
            detail (`bool`, *optional*):
                If True, returns a dict mapping paths to file information. Defaults to False.
            refresh (`bool`, *optional*):
                If True, bypass the cache and fetch the latest data. Defaults to False.
            revision (`str`, *optional*):
                The git revision to list from.

        Returns:
            `Union[list[str], dict[str, dict[str, Any]]]`: List of paths or dict of file information.
        Nr   zmaxdepth must be at least 1rÊ   T)rÓ   rå   rÔ   c                 ó*   — g | ]}|d          dk    ¯|‘ŒS rô   rC   rí   s     r:   rÚ   z%HfFileSystem.find.<locals>.<listcomp>  s&   € ÐBÐBÐB˜Q¨¨6¬°kÒ)AÐ)A�qÐ)AÐ)AÐ)Ar<   rr   rõ   c                 ó    — i | ]}|d          |“ŒS rè   rC   rí   s     r:   r•   z%HfFileSystem.find.<locals>.<dictcomp>  s   € Ð-Ð-Ð- A�1�V”9˜aÐ-Ð-Ð-r<   rH   r  c                 ó"   •— i | ]}|‰|         “ŒS rC   rC   )r“   ré   rï   s     €r:   r•   z%HfFileSystem.find.<locals>.<dictcomp>  s   ø€ Ð6Ð6Ð6¨�D˜#˜dœ)Ð6Ð6Ð6r<   )r©   r»   r;   rî   Úinfor   ÚFileNotFoundErrorr–   )r9   r3   rÔ   r2  rä   rå   rH   rf   rÀ   r÷   Únamesrï   s              @r:   ÚfindzHfFileSystem.findÚ  sœ  ø€ ð@ Ð H¨q¢L LÝÐ:Ñ;Ô;Ð;Ø×)Ò)¨$¸Ð)ÑBÔBˆØ×&Ò&Ñ(Ô(ˆð	.Ø�$”- Ðc°¸gÐPXÐcÐcÐ\bÐcÐcˆCð ð UØBÐB #ÐBÑBÔB��ð &˜DœI dÐ5Ð5¨fÐ5Ð5�	Ø+4°VÔ+<ÀÒ+KÐ+K�y�k CÑ'Ð'ÐQT�Ø-Ð-¨Ð-Ñ-Ô-ˆCˆCøõ! "ð 	ð 	ð 	ðØ�4”9˜TÐ?Ð?¨HÐ?¸Ð?Ð?ÀÔGÈ6ÒQÐQØ ˜*�C�Cà�CøøÝ$ð ð ð Ø���ðøøøøøð	øøøõ" �s‘”ˆØð 	7ØˆLà6Ð6Ð6Ð6°Ð6Ñ6Ô6Ð6s6   ÁB Â
CÂ !CÃCÃCÃCÃCÃCÃCÚpath1Úpath2c                 ó  — |                       ||¬¦  «        }|                       ||¬¦  «        }t          |t          ¦  «        st          |t          ¦  «        rt          d¦  «        ‚|j        |j        k    o|j        |j        k    }|r€d|› d|› �}| j                             |j        |j        |j        | 	                    d|¦  «        | 	                    dd¦  «        t          |j        |j        |j        ¬¦  «        g¬	¦  «         n³|                      |d
|j        ¬¦  «        5 }	|	                     ¦   «         }
ddd¦  «         n# 1 swxY w Y   d|› d|› �}| j                             |
|j        |j        | j        |j        |j        | 	                    d|¦  «        | 	                    d¦  «        ¬¦  «         |                      |                     ¦   «         ¬¦  «         |                      |                     ¦   «         ¬¦  «         dS )aš  
        Copy a file within or between repositories.

        > [!WARNING]
        > Note: When possible, use `HfApi.upload_file()` for better performance.

        Args:
            path1 (`str`):
                Source path to copy from.
            path2 (`str`):
                Destination path to copy to.
            revision (`str`, *optional*):
                The git revision to copy from.

        rÊ   z)Copy from/to buckets is not available yetzCopy z to rÍ   rÎ   rP   )Úsrc_path_in_reporI   Úsrc_revision)rG   rF   rH   rÍ   rÎ   rÞ   rÂ   N©Úpath_or_fileobjrI   rG   r‡   rF   rH   rÍ   rÎ   rÏ   )r»   r¿   rY   r§   rF   rG   rŒ   rà   rH   rS   r   rI   ÚopenÚreadÚupload_filer‡   rÁ   r;   )r9   r;  r<  rH   rf   Úresolved_path1Úresolved_path2Ú	same_reporÍ   ÚfÚcontents              r:   Úcp_filezHfFileSystem.cp_file  s{  € ð  ×*Ò*¨5¸8Ð*ÑDÔDˆØ×*Ò*¨5¸8Ð*ÑDÔDˆÝ�nÕ&DÑEÔEð 	SÍØÕ:ñJ
ô J
ð 	Sõ &Ð&QÑRÔRÐRð Ô$¨Ô(@Ò@ÐuÀ^ÔE[Ð_mÔ_uÒEuð 	ð ð 	Ø7 UÐ7Ð7°Ð7Ð7ˆNØŒI×#Ò#Ø&Ô.Ø(Ô2Ø'Ô0Ø%ŸzšzÐ*:¸NÑKÔKØ#)§:¢:Ð.BÀBÑ#GÔ#Gå'Ø)7Ô)DØ%3Ô%@Ø%3Ô%<ðñ ô ðð $ñ ô ð ð ð —’˜5 $°Ô1H�ÑIÔIð #ÈQØŸ&š&™(œ(�ð#ð #ð #ñ #ô #ð #ð #ð #ð #ð #ð #øøøð #ð #ð #ð #à7 UÐ7Ð7°Ð7Ð7ˆNØŒI×!Ò!Ø 'Ø+Ô8Ø&Ô.Ø”jØ(Ô2Ø'Ô0Ø%ŸzšzÐ*:¸NÑKÔKØ#)§:¢:Ð.BÑ#CÔ#Cð "ñ 	ô 	ð 	ð 	×Ò >×#;Ò#;Ñ#=Ô#=ÐÑ>Ô>Ð>Ø×Ò >×#;Ò#;Ñ#=Ô#=ÐÑ>Ô>Ð>Ð>Ð>s   Ä'EÅEÅEc                 óþ   —  | j         |fi i |¥ddi¥¤Ž}d|v r(|d         €t          d|› d�¦  «        ‚|d         j        S d|v r|d         r|d         S d|v r|d         r|d         S t          d	|› d
|› d�¦  «        ‚)ak  
        Get the last modified time of a file.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.modified).

        Args:
            path (`str`):
                Path to the file.

        Returns:
            `datetime`: Last modified time of the file.
        r‰   Trû   Nz9'modified' is not implemented for repository paths like 'r$  r  r	  z'Cannot determined 'modified' for path 'z	' (info: ú))r7  r§   Údate)r9   r3   rf   r7  s       r:   ÚmodifiedzHfFileSystem.modifiedS  sË   € ð ˆtŒy˜ÐAÐAÐ!@ FÐ!@¨M¸4Ð!@Ð!@ÐAÐAˆØ˜DÐ Ð Ø�MÔ"Ð*Ý)Ð*mÐfjÐ*mÐ*mÐ*mÑnÔnÐnØ˜Ô&Ô+Ð+Ø˜ˆ_ˆ_  g¤ˆ_Ø˜”=Ð Ø˜dÐ"Ð" t¨MÔ':Ð"Ø˜Ô&Ð&å%Ð&fÐPTÐ&fÐ&fÐ_cÐ&fÐ&fÐ&fÑgÔgÐgr<   c           	      óÖ  ‡‡— |                       ‰|¬¦  «        }|                     ¦   «         Š|                     d| j        �| j        nd¦  «        }|j        s“‰dddœŠt          |t          ¦  «        rd‰d<   t          |t          ¦  «        r\|rZ| j                             |j	        |j
        |j        ¬	¦  «        d
         }i ‰¥dt          |j        |j        |j        ¬¦  «        dœ¥Š�nùt          |t           ¦  «        ra|                      ‰¦  «        }|                      ||¬¦  «         ˆfd„| j        |         D ¦   «         }	|	st)          ‰d¦  «         |	d         Š�nƒdŠ|                      ‰¦  «        }|s|| j        vr|                      |¦  «         || j        v r3ˆfd„| j        |         D ¦   «         }	|	st)          ‰d¦  «         |	d         Š|s‰�|�r	‰�r‰d         €þ| j                             |j	        |j        ||j        |j
        ¬¦  «        }
|
st)          ‰d¦  «         |
d         }t          |j
        |j	        |j        d|j        ¬¦  «                             ¦   «         }t          |t0          ¦  «        r5|dz   |j        z   |j        d|j        |j        |j        |j        |j        dœŠn|dz   |j        z   dd|j        |j        dœŠ|sˆfd„dD ¦   «         Š‰€J ‚‰S )aS  
        Get information about a file or directory.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.info).

        > [!WARNING]
        > Note: When possible, use `HfApi.get_paths_info()` or `HfApi.repo_info()`  for better performance
        > (or `HfApi.get_bucket_paths_info()` or `HfApi.bucket_info()` for buckets)

        Args:
            path (`str`):
                Path to get info for.
            refresh (`bool`, *optional*):
                If True, bypass the cache and fetch the latest data. Defaults to False.
            revision (`str`, *optional*):
                The git revision to get info from.

        Returns:
            `dict[str, Any]`: Dictionary containing file information (type, size, commit info, etc.).

        rÊ   r‰   NFr   rõ   )ré   r  rr   rû   )rF   rH   éÿÿÿÿ)ÚoidÚtitlerM  )r  rû   )rå   c                 ó,   •— g | ]}|d          ‰k    ¯|‘ŒS rè   rC   rê   s     €r:   rÚ   z%HfFileSystem.info.<locals>.<listcomp>   s'   ø€ ÐOÐOÐO˜!¸Q¸v¼YÈ$Ò=NÐ=N�AÐ=NÐ=NÐ=Nr<   c                 ó,   •— g | ]}|d          ‰k    ¯|‘ŒS rè   rC   rê   s     €r:   rÚ   z%HfFileSystem.info.<locals>.<listcomp>¬  s'   ø€ ÐSÐSÐS˜aÀÀ6ÄÈdÒARÐAR˜ÐARÐARÐARr<   )r   rH   rF   rP   )rI   rN   r6   r  r  r
  c                 ó"   •— i | ]}|‰|         “ŒS rC   rC   )r“   Úkrï   s     €r:   r•   z%HfFileSystem.info.<locals>.<dictcomp>Ö  s   ø€ ÐGÐGÐG¨˜1˜c !œfÐGÐGÐGr<   ) r»   r;   rS   r‰   r3   r¿   rE   rŒ   Úlist_repo_commitsrG   rF   rH   r'   Ú	commit_idrR  Ú
created_atrY   r¾   rð   r�   r­   Úget_paths_inforI   rN   r(   r  r  r  r  rû   r  r  )r9   r3   rå   rH   rf   rÀ   r‰   rû   r"  Úout1Ú
paths_infor÷   r  rï   s    `           @r:   r7  zHfFileSystem.infol  s¨  øø€ ð, ×)Ò)¨$¸Ð)ÑBÔBˆØ×&Ò&Ñ(Ô(ˆØ—j’jØ¨tÔ/?Ð/K˜4Ô+Ð+ÐQVñ
ô 
ˆð Ô!ð N	Hð ØØ#ðð ˆCõ
 ˜-Õ)KÑLÔLð *Ø%)��MÑ"Ý˜-Õ)KÑLÔLð 
ÐQ\ð 
Ø"œi×9Ò9Ø!Ô)°]Ô5LÐWdÔWmð :ñ ô àô�ðØðà#Ý#1Ø'Ô1¸Ô9JÐQ\ÔQgð$ñ $ô $ðð ð �ùõ ˜Õ'EÑFÔFð :	HØŸ,š, tÑ,Ô,ˆKà�GŠG�K¨ˆGÑ1Ô1Ð1ØOÐOÐOÐO˜tœ}¨[Ô9ÐOÑOÔOˆDØð 2Ý% d¨DÑ1Ô1Ð1Ø�q”'ˆC‰CàˆCØŸ,š, tÑ,Ô,ˆKØð % ;°d´mÐ#CÐ#Cà—’˜Ñ$Ô$Ð$Ø˜dœmÐ+Ð+àSÐSÐSÐS 4¤=°Ô#=ÐSÑSÔS�Øð 6Ý)¨$°Ñ5Ô5Ð5Ø˜1”g�Øð &H˜#˜+¨+™+¸#™+À#ÀmÔBTÐB\Ø!œY×5Ò5Ø!Ô)Ø!Ô.Ø&Ø*Ô3Ø+Ô5ð 6ñ ô �
ð "ð 6Ý)¨$°Ñ5Ô5Ð5Ø& qœM�	Ý>Ø!Ô+Ø!Ô)Ø!Ô*Ø!#Ø"/Ô"=ðñ ô ÷ ’)‘+”+ð õ ˜i­Ñ2Ô2ð à )¨C¡°)´.Ñ @Ø )¤Ø &Ø#,Ô#4Ø(œ}Ø$-Ô$6Ø'0Ô'<Ø$-Ô$6ð	ð 	�C�Cð !*¨C¡°)´.Ñ @Ø !Ø +Ø#,Ô#4Ø'0Ô'<ðð �Cð #ð HØGÐGÐGÐGÐ.FÐGÑGÔG�CØˆˆˆØˆ
r<   c                 óœ   — 	 |                      dd¦  «        r|                      |¦  «          | j        |fi |¤Ž dS # t          $ r Y dS w xY w)aÁ  
        Check if a file exists.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.exists).

        > [!WARNING]
        > Note: When possible, use `HfApi.file_exists()` for better performance.

        Args:
            path (`str`):
                Path to check.

        Returns:
            `bool`: True if file exists, False otherwise.
        rå   FT)rS   rÁ   r7  ÚOSError)r9   r3   rf   s      r:   ÚexistszHfFileSystem.existsÚ  sr   € ð 	Ø�zŠz˜) UÑ+Ô+ð ,Ø×%Ò% dÑ+Ô+Ð+àˆDŒI�dÐ%Ð%˜fÐ%Ð%Ð%Ø�4øÝð 	ð 	ð 	Ø�5�5ð	øøøs   ‚9= ½
AÁ
Ac                 ód   — 	 |                       |¦  «        d         dk    S # t          $ r Y dS w xY w)ai  
        Check if a path is a directory.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.isdir).

        Args:
            path (`str`):
                Path to check.

        Returns:
            `bool`: True if path is a directory, False otherwise.
        rr   rõ   F©r7  r^  ©r9   r3   s     r:   rØ   zHfFileSystem.isdiró  sC   € ð	Ø—9’9˜T‘?”? 6Ô*¨kÒ9Ð9øÝð 	ð 	ð 	Ø�5�5ð	øøøó   ‚! ¡
/®/c                 ód   — 	 |                       |¦  «        d         dk    S # t          $ r Y dS w xY w)a`  
        Check if a path is a file.

        For more details, refer to [fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.isfile).

        Args:
            path (`str`):
                Path to check.

        Returns:
            `bool`: True if path is a file, False otherwise.
        rr   r  Fra  rb  s     r:   ÚisfilezHfFileSystem.isfile  sC   € ð	Ø—9’9˜T‘?”? 6Ô*¨fÒ4Ð4øÝð 	ð 	ð 	Ø�5�5ð	øøørc  c                 óZ  — |                       |¦  «        }t          |t          ¦  «        r'| j        › d|j        › dt          |j        ¦  «        › �}n-t          |j        |j	        |j
        |j        | j        ¬¦  «        }|                      |¦  «        r|                     ddd¦  «        }|S )zÝ
        Get the HTTP URL of the given path.

        Args:
            path (`str`):
                Path to get URL for.

        Returns:
            `str`: HTTP URL to access the file or directory on the Hub.
        z	/buckets/z	/resolve/)rF   rH   r†   z/tree/r   )r»   r¿   rY   r†   rZ   r   r3   r!   rG   rI   rF   rH   rØ   Úreplace)r9   r3   rÀ   Úurls       r:   rh  zHfFileSystem.url  s¹   € ð ×)Ò)¨$Ñ/Ô/ˆÝ�mÕ%CÑDÔDð 		Ø”]ÐjÐj¨]Ô-DÐjÐjÍuÐUbÔUgÑOhÔOhÐjÐjˆCˆCåØÔ%ØÔ*Ø'Ô1Ø&Ô/Øœðñ ô ˆCð �:Š:�dÑÔð 	8Ø—+’+˜k¨8°QÑ7Ô7ˆCØˆ
r<   c                 óˆ  •— |                      d¦  «        }t          |                     ¦   «         ¦  «        dhz
  }t          |t          t
          f¦  «        rt          |¦  «        dk    r t          ¦   «         j        ||f||dœ|¤ŽS t          |¦  «        r|}n-|  
                    |¦  «        rt          j        |d¬¦  «         dS t          |t          t          f¦  «        r3t          j        t          j                             |¦  «        d¬¦  «         d}|€t#          |d¦  «        }d}|                     ¦   «         }	|                      ||¬	¦  «        }
|                      ||¬	¦  «        d
         }|                     |¦  «         	 t-          |                      |
                     ¦   «         ¦  «        |||d| j                             ¦   «         t          |t
          ¦  «        r|j        nd¬¦  «         |                     |	¦  «         |r|                     ¦   «          dS dS # |r|                     ¦   «          w w xY w)ad  
        Copy single remote file to local.

        > [!WARNING]
        > Note: When possible, use `HfApi.hf_hub_download()` or `HfApi.download_bucket_files` for better performance.

        Args:
            rpath (`str`):
                Remote path to download from.
            lpath (`str`):
                Local path to download to.
            callback (`Callback`, *optional*):
                Optional callback to track download progress. Defaults to no callback.
            outfile (`IO`, *optional*):
                Optional file-like object to write to. If provided, `lpath` is ignored.

        rH   r   )ÚcallbackÚoutfileT)Úexist_okNFÚwbrÊ   r  )rh  Ú	temp_fileÚdisplayed_filenameÚexpected_sizeÚresume_sizeÚheadersÚ	_tqdm_bar)rS   ÚsetÚkeysr¿   r   r   r°   ra   Úget_filer   rØ   r  ÚmakedirsrA   r   r3   ÚdirnamerB  Útellr»   r7  Úset_sizer"   rh  r;   rŒ   Ú_build_hf_headersÚtqdmÚseekÚclose)r9   ÚrpathÚlpathrj  rk  rf   rH   Úunhandled_kwargsÚ
close_fileÚinitial_posÚresolve_remote_pathrp  rg   s               €r:   rv  zHfFileSystem.get_file1  sF  ø€ ð$ —:’:˜jÑ)Ô)ˆÝ˜vŸ{š{™}œ}Ñ-Ô-°°Ñ<ÐÝ˜(¥\µ<Ð$@ÑAÔAð 	`ÅSÐIYÑEZÔEZÐ]^ÒE^ÐE^ð $•5‘7”7Ô# E¨5Ð_¸8ÈWÐ_Ð_ÐX^Ð_Ð_Ð_õ �eÑÔð 	ØˆGˆGØ�ZŠZ˜ÑÔð 	ÝŒK˜¨Ð-Ñ-Ô-Ð-Ø�4å�e�c¥4˜[Ñ)Ô)ð 	?ÝŒK�œŸš¨Ñ.Ô.¸Ð>Ñ>Ô>Ð>ð ˆ
Øˆ?Ý˜5 $Ñ'Ô'ˆGØˆJØ—l’l‘n”nˆð #×/Ò/°ÀÐ/ÑIÔIÐØŸ	š	 %°(˜	Ñ;Ô;¸FÔCˆØ×Ò˜-Ñ(Ô(Ð(ð	 ÝØ—H’HÐ0×:Ò:Ñ<Ô<Ñ=Ô=Ø!Ø#(Ø+ØØœ	×3Ò3Ñ5Ô5Ý+5°hÅÑ+MÔ+MÐW˜(œ-˜-ÐSWðñ ô ð ð �LŠL˜Ñ%Ô%Ð%ð ð  Ø—’‘”���ð ð  øˆzð  Ø—’‘”��ð øøøs   ÆBH( È(Ic                 ó    — t          d¦  «        ‚)z½A context within which files are committed together upon exit

        Requires the file class to implement `.commit()` and `.discard()`
        for the normal and exception cases.
        ú(Transactional commits are not supported.©r§   r8   s    r:   ÚtransactionzHfFileSystem.transactiono  s   € õ "Ð"LÑMÔMÐMr<   c                 ó    — t          d¦  «        ‚)z@Begin write transaction for deferring files, non-context versionr†  r‡  r8   s    r:   Ústart_transactionzHfFileSystem.start_transactionz  s   € õ "Ð"LÑMÔMÐMr<   c                 ón   — t           t          | ¦  «        | j        | j        |                      ¦   «         ffS r`   )Úmake_instancerr   rx   ry   rt   r8   s    r:   Ú
__reduce__zHfFileSystem.__reduce__€  s8   € åÝ�‰JŒJØÔØÔ Ø×$Ò$Ñ&Ô&ð	
ð 
ð 	
r<   c                 óz   — t          | j        ¦  «        t          | j        ¦  «        t          | j        ¦  «        dœS )N)r�   r�   rŽ   )r   r�   r�   rŽ   r8   s    r:   rt   z HfFileSystem._get_instance_state‰  s:   € å  ¤Ñ/Ô/Ý/7¸Ô8\Ñ/]Ô/]Ý$,¨TÔ-FÑ$GÔ$Gð
ð 
ð 	
r<   r`   )rÂ   NN)FNN)TFN)FFNNN)NFFFN)FN©r4   N)5r=   r>   r?   r@   Úroot_markerÚprotocolrA   ÚboolÚintrb   Úclassmethodrk   ÚtupleÚ	Exceptionr¡   r¤   rE   rY   r»   rÁ   r   rÈ   rÒ   rã   r  Údictr   rð   rî   r   r$   r%   r  r   r/  r1  r:  rJ  r
   rN  r7  r_  rØ   re  rh  r   rv  Úpropertyrˆ  rŠ  r�  rt   r�   r‚   s   @r:   r„   r„   Œ   s�  ø€ € € € € ð@ð @ðD €KØ€Hð
  $Ø#'Ø!%Ø#'ð<ð <ð <ð ˜‘*ð<ð �c‰z˜DÑ ð	<ð
 ˜$‘Jð<ð ˜D‘[ð<ð <ð <ð <ð <ð <ð2 ð	¨ð 	Àð 	ð 	ð 	ñ „[ð	ðTØðTØ'*ðTØ69¸D±jðTà	ˆt�Y Ñ%Ð%Ô	&ðTð Tð Tð Tð&4¨ð 4°°d¸IÈÑ<LÐ6LÔ0Mð 4ð 4ð 4ð 4ð 15ðM
ð M
ØðM
Ø#&¨¡:ðM
à	+Ð.LÑ	LðM
ð M
ð M
ð M
ð^Qð Q S¨4¡Zð Q¸4ð Qð Qð Qð QðH Ø!%Ø#ðXð XàðXð ðXð ˜$‘Jð	Xð
 ˜‘*ðXð 
Ð;Ô	<ðXð Xð Xð Xð$>ð >˜ð > s¨T¡zð >Àtð >ð >ð >ð >ð&  Ø#Ø#ð0>ð 0>àð0>ð ð0>ð ˜‘*ð	0>ð
 ˜‘*ð0>ð 
ð0>ð 0>ð 0>ð 0>ðf ]að);ð );Øð);Ø!%ð);Ø7;ð);ØORÐUYÉzð);à	ˆc�D˜˜c˜”NÑ"Ô	#ð);ð );ð );ð );ð\  ØØ#Ø#'Ø#ðKð KàðKð ðKð ð	Kð
 ˜‘*ðKð ˜D‘[ðKð ˜‘*ðKð Kð Kð KðZ&Øð&Ø&)ð&Ø6:ð&à	�*˜|Ñ+Ô	,ð&ð &ð &ð &ðP7˜ð 7°(¸5ÀÀdÈ3ÄiÐQUÐVYÔQZÐAZÔ;[Ô2\ð 7ð 7ð 7ð 7ð 7ð 7ð ?ð ?˜ð ?¨¨d©
ð ?ÈÈSÌ	ð ?ð ?ð ?ð ?ð ?ð ?ð*  $ØØØØ#ð;7ð ;7àð;7ð ˜‘*ð;7ð ð	;7ð
 ð;7ð ð;7ð ˜‘*ð;7ð 
ˆcŒ�T˜#˜t C¨ Hœ~Ð-Ô.Ñ	.ð;7ð ;7ð ;7ð ;7ðz:?ð :?˜Sð :?¨ð :?¸¸d¹
ð :?ÐX\ð :?ð :?ð :?ð :?ðxh˜Sð h¨xð hð hð hð hð2lð l˜ð l tð l¸sÀT¹zð lÐ_cÐdgÐilÐdlÔ_mð lð lð lð lð\ð ð ð2ð ð ð$ð ð ð$˜ð  ð ð ð ð ð4 /@Èð < ð < ð < ð < ð < ð < ð < ð| ðNð Nñ „XðNðNð Nð Nð
ð 
ð 
ð
ð 
ð 
ð 
ð 
ð 
ð 
r<   r„   )Ú	metaclassc                   ó„   ‡ — e Zd Zddedededz  fˆ fd„Zˆ fd„Zdeded	efd
„Z	dd„Z
dded	dfd„Zdˆ fd„	Zd	efd„Zˆ xZS )rÄ   NÚfsr3   rH   c                 ó(  •— 	 |                      ||¬¦  «        | _        n># t          $ r1}d|                     dd¦  «        v rt          |› d�¦  «        |‚‚ d }~ww xY w t	          ¦   «         j        || j                             ¦   «         fi |¤Ž |  d S )NrÊ   ÚwrÃ   rP   zB.
Make sure the repository and revision exist before writing data.)r»   rÀ   r8  rS   ra   rb   r;   )r9   r›  r3   rH   rf   r    rg   s         €r:   rb   zHfFileSystemFile.__init__’  s¿   ø€ ð	Ø!#§¢°À Ñ!IÔ!IˆDÔÐøÝ ð 	ð 	ð 	Ø�f—j’j ¨Ñ,Ô,Ð,Ð,Ý'ØÐ]Ð]Ð]ñô àðð øøøøð	øøøð 	�‰ŒÔ˜˜TÔ/×9Ò9Ñ;Ô;ÐFÐF¸vÐFÐFÐFØÐÐÐs   ƒ   
Aª,AÁAc                 óh   •— t          | d¦  «        sd S t          ¦   «                              ¦   «         S ©NrÀ   )Úhasattrra   Ú__del__©r9   rg   s    €r:   r¡  zHfFileSystemFile.__del__ž  s.   ø€ Ý�t˜_Ñ-Ô-ð 	àˆFÝ‰wŒw�ŠÑ Ô Ð r<   ÚstartÚendr4   c                 óæ   — dd|› d|dz
  › �i| j         j                             ¦   «         ¥}|                      ¦   «         }t	          d||t
          j        ¬¦  «        }t          |¦  «         |j        S )NÚrangeúbytes=ú-r   ÚGET©rr  rœ   )	r›  rŒ   r{  rh  r,   r   ÚHF_HUB_DOWNLOAD_TIMEOUTr+   rI  )r9   r£  r¤  rr  rh  Úrs         r:   Ú_fetch_rangezHfFileSystemFile._fetch_range¤  sy   € àÐ/˜eÐ/Ð/ c¨A¡gÐ/Ð/ð
àŒgŒl×,Ò,Ñ.Ô.ð
ˆð �hŠh‰jŒjˆÝ˜ ¨W½iÔ>_Ð`Ñ`Ô`ˆÝ˜AÑÔÐØŒyÐr<   c                 ó<   — t          j        dd¬¦  «        | _        d S )Nzhffs-F)rÿ   rÌ   )ÚtempfileÚNamedTemporaryFilern  r8   s    r:   Ú_initiate_uploadz!HfFileSystemFile._initiate_upload®  s   € Ý!Ô4¸GÈEÐRÑRÔRˆŒˆˆr<   FÚfinalc                 ó\  — | j                              d¦  «         | j                              ¦   «         }| j                             |¦  «         |�r[| j                             ¦   «          t          | j        t          ¦  «        rC| j	        j
                             | j        j        | j        j        | j        j        fg¬¦  «         n“| j	        j
                             | j        j        | j        j        | j        j        | j	        j        | j        j        | j        j        | j                             d¦  «        | j                             d¦  «        ¬¦  «         t/          j        | j        j        ¦  «         | j	                             | j                             ¦   «         ¬¦  «         d S d S )Nr   )ÚaddrÍ   rÎ   r@  rÏ   )Úbufferr}  rC  rn  Úwriter~  r¿   rÀ   rY   r›  rŒ   rÐ   rZ   ré   r3   rD  rI   rG   r‡   rF   rH   rf   rS   r  ÚremoverÁ   r;   )r9   r²  Úblocks      r:   Ú_upload_chunkzHfFileSystemFile._upload_chunk±  s�  € ØŒ×Ò˜ÑÔÐØ”× Ò Ñ"Ô"ˆØŒ×Ò˜UÑ#Ô#Ð#Øñ 	ØŒN× Ò Ñ"Ô"Ð"Ý˜$Ô,Õ.LÑMÔMð Ø””×/Ò/ØÔ&Ô0¸¼Ô8KÈTÔM_ÔMdÐ7eÐ6fð 0ñ ô ð ð ð ””×(Ò(Ø$(¤NÔ$7Ø!%Ô!3Ô!@Ø Ô.Ô6Øœ'œ-Ø"Ô0Ô:Ø!Ô/Ô8Ø#'¤;§?¢?Ð3CÑ#DÔ#DØ'+¤{§¢Ð7KÑ'LÔ'Lð )ñ 	ô 	ð 	õ ŒI�d”nÔ)Ñ*Ô*Ð*ØŒG×$Ò$ØÔ'×1Ò1Ñ3Ô3ð %ñ ô ð ð ð ð%	ð 	r<   rP  c                 ó\  •— | j         dk    r€|�|dk    rx| j        dk    rm| j                             | j        dd¬¦  «        5 }|                     ¦   «         }| xj        t          |¦  «        z  c_        |cddd¦  «         S # 1 swxY w Y   t          ¦   «                              |¦  «        S )züRead remote file.

        If `length` is not provided or is -1, the entire file is downloaded and read. On POSIX systems the file is
        loaded in memory directly. Otherwise, the file is downloaded to a temporary file and read from there.
        rÂ   NrP  r   )rˆ   )rÃ   Úlocr›  rB  r3   rC  r°   ra   )r9   ÚlengthrH  rï   rg   s       €r:   rC  zHfFileSystemFile.readË  sÚ   ø€ ð Œ9˜ÒÐ & .°F¸b²L°LÀdÄhÐRSÂmÀmØ”—’˜dœi¨¸!�Ñ<Ô<ð ÀØ—f’f‘h”h�Ø�”�C ™HœHÑ$�”Øðð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð õ ‰wŒw�|Š|˜FÑ#Ô#Ð#s   Á3BÂBÂ	Bc                 ó@   — | j                              | j        ¦  «        S r`   ©r›  rh  r3   r8   s    r:   rh  zHfFileSystemFile.urlØ  ó   € ØŒw�{Š{˜4œ9Ñ%Ô%Ð%r<   r`   r�  )F©rP  )r=   r>   r?   r„   rA   rb   r¡  r“  Úbytesr­  r±  r’  r¹  rC  rh  r�   r‚   s   @r:   rÄ   rÄ   ‘  s  ø€ € € € € ð
ð 
˜<ð 
¨sð 
¸cÀD¹jð 
ð 
ð 
ð 
ð 
ð 
ð!ð !ð !ð !ð !ð #ð ¨Cð °Eð ð ð ð ðSð Sð Sð Sðð  4ð °Dð ð ð ð ð4$ð $ð $ð $ð $ð $ð&�Sð &ð &ð &ð &ð &ð &ð &ð &r<   rÄ   c                   ó¬   ‡ — e Zd Z	 	 	 	 ddededededz  d	ed
efˆ fd„Zddedefd„Zddefd„Zdde	e
         dede
fd„Zdefd„Zˆ fd„Zd„ Zd„ Zˆ xZS )rÅ   rÂ   Nr   Únoner›  r3   rÃ   rH   rˆ   Ú
cache_typec                 óè  •— |dk    rt          d|› �¦  «        ‚|dk    rt          d|› �¦  «        ‚d|v rt          d|› d�¦  «        ‚|                     ||¬¦  «        | _        | j                             ¦   «         d d	œ| _         t          ¦   «         j        || j                             ¦   «         f|||d
œ|¤Ž d | _        |  t          ¦   «         | _	        d | _
        t          ¦   «         | _        d S )Nr   z:HfFileSystemStreamFile only supports block_size=0 but got rÃ  z?HfFileSystemStreamFile only supports cache_type='none' but got r�  z;HfFileSystemStreamFile only supports reading but got mode='r$  rÊ   )ré   r  ©rÃ   rˆ   rÄ  )r©   r»   rÀ   r;   Údetailsra   rb   Úresponser   Ú_exit_stackÚ_stream_iteratorÚ	bytearrayÚ_stream_buffer)	r9   r›  r3   rÃ   rH   rˆ   rÄ  rf   rg   s	           €r:   rb   zHfFileSystemStreamFile.__init__Ý  s#  ø€ ð ˜Š?ˆ?ÝÐfÐZdÐfÐfÑgÔgÐgØ˜ÒÐÝÐkÐ_iÐkÐkÑlÔlÐlØ�$ˆ;ˆ;ÝÐbÐ[_ÐbÐbÐbÑcÔcÐcð  Ÿ_š_¨T¸H˜_ÑEÔEˆÔà $Ô 2× <Ò <Ñ >Ô >ÈÐMÐMˆŒØ�‰ŒÔØ�Ô"×,Ò,Ñ.Ô.ð	
Ø59ÀjÐ]gð	
ð 	
Økqð	
ð 	
ð 	
ð 04ˆŒØÐÝ$™;œ;ˆÔà8<ˆÔÝ'™kœkˆÔÐÐr<   r»  Úwhencec                 ób   — |dk    r|dk    rd S || j         k    r|dk    rd S t          d¦  «        ‚)Nr   r   zCannot seek streaming HF file)r»  r©   )r9   r»  rÍ  s      r:   r}  zHfFileSystemStreamFile.seekü  s?   € Ø�!Š8ˆ8˜ !š˜ØˆFØ�$”(Š?ˆ?˜v¨š{˜{ØˆFÝÐ8Ñ9Ô9Ð9r<   rP  r¼  c                 óh  — | j         €|                      ¦   «          d}	 	 | j         �| j        €dS |                      | j        |¦  «        }| xj        t          |¦  «        z  c_        |S # t          $ r< | j         �| j                              ¦   «          |r‚ |                      ¦   «          d}Y nw xY wŒ•)zÞRead the remote file.

        If the file is already open, we reuse the connection.
        Otherwise, open a new connection and read from it.

        If reading the stream fails, we retry with a new connection.
        NFTr<   )rÈ  Ú_open_connectionrÊ  Ú_read_from_streamr»  r°   r–  r~  )r9   r¼  Úretried_oncerï   s       r:   rC  zHfFileSystemStreamFile.read  s×   € ð Œ=Ð Ø×!Ò!Ñ#Ô#Ð#àˆð	$ð$Ø”=Ð(¨DÔ,AÐ,IØ˜3Ø×,Ò,¨TÔ-BÀFÑKÔK�Ø�”�C ™HœHÑ$�”Ø�
øÝð $ð $ð $Ø”=Ð,Ø”M×'Ò'Ñ)Ô)Ð)Øð Øà×%Ò%Ñ'Ô'Ð'Ø#���ð$øøøð	$s    A* °9A* Á*AB0Â/B0Úiteratorr4   c                 óÀ  — |dk    rdS |dk     rVt          | j        ¦  «        }| j                             ¦   «          |D ]}|                     |¦  «         Œt	          |¦  «        S |t          | j        ¦  «        k    r(t	          | j        d|…         ¦  «        }| j        d|…= |S t          | j        ¦  «        }| j                             ¦   «          |D ]|}|t          |¦  «        z
  }|t          |¦  «        k    r|                     |¦  «         Œ=|                     |d|…         ¦  «         | j                             ||d…         ¦  «          t	          |¦  «        S )z°Read up to `length` bytes from stream buffer and stream.

        If length < 0, read until EOF.

        If EOF is reached before length, fewer bytes may be returned.
        r   r<   N)rË  rÌ  r½   r  rÁ  r°   )r9   rÓ  r¼  ÚbufÚchunkÚresultÚneeds          r:   rÑ  z(HfFileSystemStreamFile._read_from_stream  se  € ð �QŠ;ˆ;Ø�3à�AŠ:ˆ:Ý˜DÔ/Ñ0Ô0ˆCØÔ×%Ò%Ñ'Ô'Ð'Ø!ð "ð "�Ø—
’
˜5Ñ!Ô!Ð!Ð!Ý˜‘:”:Ðà•S˜Ô,Ñ-Ô-Ò-Ð-Ý˜4Ô.¨w°¨wÔ7Ñ8Ô8ˆFØÔ# G V GÐ,ØˆMå˜Ô+Ñ,Ô,ˆØÔ×!Ò!Ñ#Ô#Ð#Øð 	ð 	ˆEØ�C ™HœHÑ$ˆDØ•c˜%‘j”jÒ Ð Ø—
’
˜5Ñ!Ô!Ð!Ð!à—
’
˜5  $ œ<Ñ(Ô(Ð(ØÔ#×*Ò*¨5°°°¬<Ñ8Ô8Ð8ØÝ�S‰zŒzÐr<   c                 ó@   — | j                              | j        ¦  «        S r`   r¾  r8   s    r:   rh  zHfFileSystemStreamFile.urlA  r¿  r<   c                 óš   •— t          | d¦  «        sd S | j                             ¦   «          t          ¦   «                              ¦   «         S rŸ  )r   rÉ  r~  ra   r¡  r¢  s    €r:   r¡  zHfFileSystemStreamFile.__del__D  sC   ø€ Ý�t˜_Ñ-Ô-ð 	àˆFØÔ×ÒÑ Ô Ð Ý‰wŒw�ŠÑ Ô Ð r<   c                 óZ   — t           | j        | j        | j        | j        | j        j        ffS r`   )Úreopenr›  r3   rÃ   Ú	blocksizeÚcacheré   r8   s    r:   r�  z!HfFileSystemStreamFile.__reduce__K  s$   € Ý˜œ ¤¨D¬I°t´~ÀtÄzÄÐWÐWÐWr<   c                 ó  — | j                              ¦   «          d| _        |                      ¦   «         }| j        j                             ¦   «         }| j        dk    rd| j        › d�|d<   | j         	                    t          d||t          j        ¬¦  «        ¦  «        | _        	 t          | j        ¦  «         n0# t          $ r#}|j        j        dk    rd| _        Y d}~dS ‚ d}~ww xY w| j                             ¦   «         | _        dS )	z%Open a connection to the remote file.Nr   r§  r¨  ÚRanger©  rª  i   )rÌ  r½   rÊ  rh  r›  rŒ   r{  r»  rÉ  Úenter_contextr-   r   r«  rÈ  r+   r   Ústatus_codeÚ
iter_bytes)r9   rh  rr  r    s       r:   rÐ  z'HfFileSystemStreamFile._open_connectionN  s  € ð 	Ô×!Ò!Ñ#Ô#Ð#Ø $ˆÔà�hŠh‰jŒjˆØ”'”,×0Ò0Ñ2Ô2ˆØŒ8�aŠ<ˆ<Ø3¨¬Ð3Ð3Ð3ˆG�GÑØÔ(×6Ò6ÝØØØÝ!Ô9ð	ñ ô ñ
ô 
ˆŒð	Ý ¤Ñ.Ô.Ð.Ð.øÝð 	ð 	ð 	ØŒzÔ%¨Ò,Ð,à $�”Ø�����Øøøøøð	øøøð !%¤× 8Ò 8Ñ :Ô :ˆÔÐÐs   Â'B< Â<
C)ÃC$Ã#C$Ã$C))rÂ   Nr   rÃ  )r   rÀ  )r=   r>   r?   r„   rA   r“  rb   r}  rC  r   rÁ  rÑ  rh  r¡  r�  rÐ  r�   r‚   s   @r:   rÅ   rÅ   Ü  s^  ø€ € € € € ð
 Ø#ØØ ð*ð *àð*ð ð*ð ð	*ð
 ˜‘*ð*ð ð*ð ð*ð *ð *ð *ð *ð *ð>:ð :˜ð : Sð :ð :ð :ð :ð$ð $˜3ð $ð $ð $ð $ð8 ð  ¨(°5¬/ð  À3ð  ÐPUð  ð  ð  ð  ðD&�Sð &ð &ð &ð &ð!ð !ð !ð !ð !ðXð Xð Xð;ð ;ð ;ð ;ð ;ð ;ð ;r<   rÅ   rH   r4   c                 óL   — t          j        | ¦  «        r| nt          | ¦  «        S r`   )r#   ÚmatchÚ
safe_quoterÊ   s    r:   rU   rU   m  s%   € Ý2Ô8¸ÑBÔBÐ\ˆ8ˆ8Í
ÐS[ÑH\ÔH\Ð\r<   Úsc                 ó$   — t          | d¬¦  «        S )NrP   )Úsafe)r   )rç  s    r:   ræ  ræ  q  s   € Ý�˜ÐÑÔÐr<   r3   r³   c                 óÆ   — | }t          |t          ¦  «        r| › d�}n5t          |t          ¦  «        r| › d�}nt          |t          ¦  «        r| › d�}t	          |¦  «        |‚)Nz (repository not found)z (revision not found)z (invalid repository id))r¿   r   r    r*   r8  )r3   r³   Úmsgs      r:   r­   r­   u  s~   € Ø
€CÝ�#Õ.Ñ/Ô/ð 0ØÐ.Ð.Ð.ˆˆÝ	�CÕ.Ñ	/Ô	/ð 0ØÐ,Ð,Ð,ˆˆÝ	�CÕ*Ñ	+Ô	+ð 0ØÐ/Ð/Ð/ˆÝ
˜CÑ
 Ô
  cÐ)r<   r›  rÃ   rˆ   rÄ  c                 ó4   — |                       ||||¬¦  «        S )NrÆ  )rB  )r›  r3   rÃ   rˆ   rÄ  s        r:   rÜ  rÜ  €  s   € Ø�7Š7�4˜d¨zÀjˆ7ÑQÔQÐQr<   c                 ól   —  | |i |¤Ž}|                      ¦   «         D ]\  }}t          |||¦  «         Œ|S r`   )ru   rv   )rd   re   rf   r~   r›  r   r€   s          r:   rŒ  rŒ  „  sP   € Ø	ˆˆdÐ	�fÐ	Ð	€BØ+×1Ò1Ñ3Ô3ð 'ð 'ÑˆˆkÝ��D˜+Ñ&Ô&Ð&Ð&Ø€Ir<   )Zr  r¯  rl   Úcollectionsr   Úcollections.abcr   r   Ú
contextlibr   Úcopyr   Údataclassesr   r	   r
   Ú	itertoolsr   Úpathlibr   r   Útypingr   r   r   Úurllib.parser   r   ÚfsspecÚhttpxÚfsspec.callbacksr   r   r   Úfsspec.configr   Úfsspec.utilsr   rP   r   Ú_commit_apir   r   Úerrorsr   r   r   r   r    Úfile_downloadr!   r"   Úhf_apir#   r$   r%   r&   r'   r(   r)   Úutilsr*   r+   r,   r-   r.   Úutils.insecure_hashlibr/   r1   rE   rY   rr   ÚAbstractFileSystemr\   rB   r^   r„   ÚspecÚAbstractBufferedFilerÄ   rÅ   rA   rU   ræ  r–  r­   r“  rÜ  rŒ  ÚhffsrC   r<   r:   ú<module>r     sÀ  ðØ 	€	€	€	€	Ø €€€Ø Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'à €€€Ø €€€Ø JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ &Ð &Ð &Ð &Ð &Ð &Ø #Ð #Ð #Ð #Ð #Ð #à Ð Ð Ð Ð Ð Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cðð ð ð ð ð ð ð ð ð ð ð ð ð ð 0Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vÐ vØ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jØ 'Ð 'Ð 'Ð 'Ð 'Ð 'ð ð6ð 6ð 6ð 6ð 6ñ 6ô 6ñ „ð6ð ð&ð &ð &ð &ð &Ð)Añ &ô &ñ „ð&ð0 ð0ð 0ð 0ð 0ð 0Ð%=ñ 0ô 0ñ „ð0ð �D˜Ô2Ñ3Ô3€ˆcÐ 3Ð 3Ñ 3ð2ð 2ð 2ð 2ð 2ˆlñ 2ô 2ð 2ðjB
ð B
ð B
ð B
ð B
�6Ô,¸ð B
ñ B
ô B
ð B
ðJ H&ð H&ð H&ð H&ð H&�v”{Ô7ñ H&ô H&ð H&ðVN;ð N;ð N;ð N;ð N;˜Vœ[Ô=ñ N;ô N;ð N;ðb]˜Cð ] Cð ]ð ]ð ]ð ]ð�#ð ˜#ð ð ð ð ð* ð *¨)°dÑ*:ð *¸xð *ð *ð *ð *ðRˆ|ð R 3ð R¨cð R¸sð RÐPSð Rð Rð Rð Rðð ð ð €|�~„~€€€r<   