Ë
    Q^(hŒ¹  ã            
       ó„  — 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 d dlmZmZmZmZmZmZmZmZ d dlmZm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* ddl+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5  ejl                  dejn                  «      Z8e G d„ d«      «       Z9 G d„ dejt                  «      Z; G d„ dejx                  jz                  «      Z> G d„ dejx                  jz                  «      Z?de@de@fd„ZAde@de@fd „ZBd!e@d"eeC   defd#„ZDd$e;d!e@d%e@d&eEd'e@f
d(„ZFy))é    N)Údeque)Ú	dataclassÚfield)Údatetime)Úchain)ÚPath)ÚAnyÚDictÚIteratorÚListÚNoReturnÚOptionalÚTupleÚUnion)ÚquoteÚunquote)Ú_DEFAULT_CALLBACKÚNoOpCallbackÚTqdmCallback)Ú
isfilelike)ÚResponseé   )Ú	constants)ÚCommitOperationCopyÚCommitOperationDelete)ÚEntryNotFoundErrorÚRepositoryNotFoundErrorÚRevisionNotFoundError)Ú
hf_hub_urlÚhttp_get)ÚHfApiÚLastCommitInfoÚRepoFile)ÚHFValidationErrorÚhf_raise_for_statusÚhttp_backoffzy
    (^refs\/convert\/\w+)     # `refs/convert/parquet` revisions
    |
    (^refs\/pr\/\d+)          # PR revisions
    c                   ój   — e Zd ZU dZeed<   eed<   eed<   eed<    edd¬«      Zee   ed	<   d
efd„Z	y)ÚHfFileSystemResolvedPathzUData structure containing information about a resolved Hugging Face file system path.Ú	repo_typeÚrepo_idÚrevisionÚpath_in_repoNF)ÚdefaultÚreprÚ_raw_revisionÚreturnc                 óÈ  — t         j                  j                  | j                  d«      | j                  z   }| j
                  r-|› d| j
                  › d| j                  › �j                  d«      S | j                  t         j                  k7  r6|› dt        | j                  «      › d| j                  › �j                  d«      S |› d| j                  › �j                  d«      S )NÚ ú@ú/)r   ÚREPO_TYPES_URL_PREFIXESÚgetr)   r*   r/   r,   Úrstripr+   ÚDEFAULT_REVISIONÚsafe_revision)ÚselfÚ	repo_paths     ú\/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/huggingface_hub/hf_file_system.pyÚ	unresolvez"HfFileSystemResolvedPath.unresolve0   sÍ   € Ü×5Ñ5×9Ñ9¸$¿.¹.È"ÓMÐPT×P\ÑP\Ñ\ˆ	Ø×ÒØ�[  $×"4Ñ"4Ð!5°Q°t×7HÑ7HÐ6IÐJ×QÑQÐRUÓVÐVØ�]‰]œi×8Ñ8Ò8Ø�[ ¤-°·±Ó">Ð!?¸qÀ×ARÑARÐ@SÐT×[Ñ[Ð\_Ó`Ð`à�[  $×"3Ñ"3Ð!4Ð5×<Ñ<¸SÓAÐAó    )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   r/   r   r=   © r>   r<   r(   r(   $   s?   … á_àƒNØƒLØƒMØÓñ $)°¸EÔ#B€M�8˜C‘=ÓBðB˜3ô Br>   r(   c                   óì  ‡ — e Zd ZdZdZdZdddœdee   dee	edf   fˆ fd„Z
d	ed
edee   dee	ee   f   fd„Zd.dedee   defd„Zd.dee   ddfd„Z	 	 	 d/dededee   dee   ddf
d„Zd.dedee   ddfd„Z	 	 	 d0dede	dee   dee   ddf
d„Z	 d1dede	de	dee   deeeeeef   f      f
d„Z	 	 	 	 d2dede	de	dee   de	f
d„Zdedeeeee   ee   f      fˆ fd„Zdedee   fˆ fd„Z	 	 	 	 	 d3dedee   d e	de	de	dee   deee   eeeeef   f   f   fˆ fd!„Zd.d"ed#edee   ddfd$„Zdedefd%„Z d4dede	dee   deeef   fd&„Z!d'„ Z"d(„ Z#d)„ Z$dedefd*„Z%e&dfd5ˆ fd+„Z'e(d,„ «       Z)d-„ Z*ˆ xZ+S )6ÚHfFileSystema8  
    Access a remote Hugging Face Hub repository as if were a local file system.

    <Tip warning={true}>

        [`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.

    </Tip>

    Args:
        token (`str` or `bool`, *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`.
        endpoint (`str`, *optional*):
            Endpoint of the Hub. Defaults to <https://huggingface.co>.
    Usage:

    ```python
    >>> from huggingface_hub import HfFileSystem

    >>> fs = HfFileSystem()

    >>> # List files
    >>> fs.glob("my-username/my-model/*.bin")
    ['my-username/my-model/pytorch_model.bin']
    >>> fs.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 fs.open("my-username/my-model/pytorch_model.bin") as f:
    ...     data = f.read()
    >>> with fs.open("my-username/my-model/pytorch_model.bin", "wb") as f:
    ...     f.write(data)
    ```
    r2   ÚhfN©ÚendpointÚtokenrJ   rK   c                ó–   •— t        ‰| �  |i |¤Ž |xs t        j                  | _        || _        t        ||¬«      | _        i | _        y )NrI   )	ÚsuperÚ__init__r   ÚENDPOINTrJ   rK   r!   Ú_apiÚ_repo_and_revision_exists_cache)r:   rJ   rK   ÚargsÚstorage_optionsÚ	__class__s        €r<   rN   zHfFileSystem.__init__f   sK   ø€ ô 	‰Ñ˜$Ð2 /Ò2Ø Ò6¤I×$6Ñ$6ˆŒØˆŒ
Ü 8°5Ô9ˆŒ	ð ð 	Õ,r>   r)   r*   r+   r0   c                 óâ  — |||f| j                   vrR	 | j                  j                  |||t        j                  ¬«       d| j                   |||f<   d| j                   ||d f<   | j                   |||f   S # t
        t        f$ r2}d|f| j                   |||f<   d|f| j                   ||d f<   Y d }~ŒNd }~wt        $ r0}d|f| j                   |||f<   d| j                   ||d f<   Y d }~Œ…d }~ww xY w)N)r+   r)   Útimeout)TNF)rQ   rP   Ú	repo_infor   ÚHF_HUB_ETAG_TIMEOUTr   r$   r   )r:   r)   r*   r+   Úes        r<   Ú_repo_and_revision_existz%HfFileSystem._repo_and_revision_existx   s!  € ð �w Ð)°×1UÑ1UÑUð^Ø—	‘	×#Ñ#Ø h¸)ÌY×MjÑMjð $ô ð Xb�×4Ñ4°iÀÈ(Ð5SÑTØS]�×4Ñ4°iÀÈ$Ð5OÑPØ×3Ñ3°YÀÈÐ4RÑSÐSøô ,Ô->Ð?ò \ØW\Ð^_ÐW_�×4Ñ4°iÀÈ(Ð5SÑTØSXÐZ[ÐS[�×4Ñ4°iÀÈ$Ð5OÖPûÜ(ò ^ØW\Ð^_ÐW_�×4Ñ4°iÀÈ(Ð5SÑTØS]�×4Ñ4°iÀÈ$Ð5OÖPûð^ús#   “-A6 Á6C.Â(B2Â2C.Â>&C)Ã)C.Úpathc                 ó  — dt         t           dt         t           dt         t           fd„}| j                  |«      }|st        d«      ‚|j	                  d«      d   dz   t
        j                  j                  «       v r8d|vrt        d«      ‚|j	                  dd«      \  }}t
        j                  |   }nt
        j                  }|j                  d«      dkD  �r¶d	|v rË|j	                  d	d«      \  }}d|v rwt        j                  |«      }|�J|d
|j                  «       fv r6t        j                  d|«      j                  d«      }|j                  «       }n|j	                  dd«      \  }}nd} |t!        |«      |«      }| j#                  |||«      \  }	}
|	�sJt%        ||
«       �n<d
}dj'                  |j	                  d«      d
d «      }dj'                  |j	                  d«      dd
 «      }|j	                  d«      d   }dj'                  |j	                  d«      dd
 «      }|}|}| j#                  |||«      \  }	}
|	s¡t)        |
t*        t,        f«      r)|}|}| j#                  |||«      \  }	}|	sot%        ||
«       nbt%        ||
«       nU|}d}d	|v r(|j	                  d	d«      \  }} |t!        |«      |«      }nd
}| j#                  |||«      \  }	}|	st        d«      ‚|�|nt
        j.                  }t1        |||||¬«      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.
        Úrevision_in_pathr+   r0   c                 óD   — |�| �| |k7  rt        d| › d|› d�«      ‚|S | }|S )NzRevision specified in path ("z ") and in `revision` argument ("z") are not the same.)Ú
ValueError)r]   r+   s     r<   Ú%_align_revision_in_path_with_revisionzHHfFileSystem.resolve_path.<locals>._align_revision_in_path_with_revisionŸ   sU   € ð Ð#Ø#Ð/Ð4DÈÒ4PÜ$Ø7Ð8HÐ7IÐIiÐjrÐisð t-ð -óð ð ˆOð ,�ØˆOr>   z0Access to repositories lists is not implemented.r4   r   r   r3   Nr2   é   )r/   )r   rC   Ú_strip_protocolÚNotImplementedErrorÚsplitr   r5   ÚvaluesÚREPO_TYPES_MAPPINGÚREPO_TYPE_MODELÚcountÚSPECIAL_REFS_REVISION_REGEXÚsearchÚgroupÚsubÚlstripr   rZ   Ú_raise_file_not_foundÚjoinÚ
isinstancer   r$   r8   r(   )r:   r[   r+   r`   r)   r*   r]   Úmatchr,   Úrepo_and_revision_existÚerrÚrepo_id_with_namespaceÚpath_in_repo_with_namespaceÚrepo_id_without_namespaceÚpath_in_repo_without_namespaceÚ_s                   r<   Úresolve_pathzHfFileSystem.resolve_path‹   s  € ð(	Ü&¤s™mð	Ü7?Ä±}ð	ä”c‰]ó	ð ×#Ñ# DÓ)ˆÙä%Ð&XÓYÐYØ�Z‰Z˜‹_˜QÑ #Ñ%¬×)JÑ)J×)QÑ)QÓ)SÑSØ˜$‰ä)Ð*\Ó]Ð]Ø"Ÿj™j¨¨aÓ0‰OˆI�tÜ!×4Ñ4°YÑ?‰Iä!×1Ñ1ˆIØ�:‰:�c‹?˜QÓØ�d‰{Ø,0¯J©J°s¸AÓ,>Ñ)�Ð)ØÐ*Ñ*Ü7×>Ñ>Ð?OÓP�EØÐ(¨X¸$ÀÇÁÃÐ9NÑ-Nä'B×'FÑ'FÀrÐK[Ó'\×'cÑ'cÐdgÓ'h˜Ø+0¯;©;«=Ñ(à9I×9OÑ9OÐPSÐUVÓ9WÑ6Ð(©,à#%�LÙ@ÄÐIYÓAZÐ\dÓe�Ø/3×/LÑ/LÈYÐX_ÐaiÓ/jÑ,Ð'¨Ú.Ü)¨$°Ö4à#'Ð Ø),¯©°$·*±*¸S³/À"À1Ð2EÓ)FÐ&Ø.1¯h©h°t·z±zÀ#³ÀqÀrÐ7JÓ.KÐ+Ø,0¯J©J°s«O¸AÑ,>Ð)Ø14·±¸$¿*¹*ÀS»/È!È"Ð:MÓ1NÐ.Ø0�Ø:�Ø/3×/LÑ/LÈYÐX_ÐaiÓ/jÑ,Ð'¨Ù.Ü! #Ô(?ÔARÐ'SÔTØ";˜Ø'E˜Ø59×5RÑ5RÐS\Ð^eÐgoÓ5pÑ2Ð/°Ù6Ü1°$¸Õ<ä-¨d°CÕ8àˆGØˆLØ�d‰{Ø,0¯J©J°s¸AÓ,>Ñ)�Ð)Ù@ÄÐIYÓAZÐ\dÓe‘à#'Ð Ø)-×)FÑ)FÀyÐRYÐ[cÓ)dÑ&Ð# QÙ*Ü)Ð*\Ó]Ð]à'Ð3‘8¼×9SÑ9SˆÜ'¨	°7¸HÀlÐbrÔsÐsr>   c                 ó  — |s5| j                   j                  «        | j                  j                  «        y| j                  |«      }|j	                  «       }|r0| j                   j                  |d«       | j                  |«      }|rŒ0|j                  sq| j                  j                  |j                  |j                  dfd«       | j                  j                  |j                  |j                  |j                  fd«       yy)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)ÚdircacheÚclearrQ   ry   r=   ÚpopÚ_parentr,   r)   r*   r+   )r:   r[   Úresolved_paths      r<   Úinvalidate_cachezHfFileSystem.invalidate_cacheê   sà   € ñ Ø�M‰M×ÑÔ!Ø×0Ñ0×6Ñ6Õ8à ×-Ñ-¨dÓ3ˆMØ ×*Ñ*Ó,ˆDÙØ—‘×!Ñ! $¨Ô-Ø—|‘| DÓ)�ò ð
 !×-Ò-Ø×4Ñ4×8Ñ8¸-×:QÑ:QÐS`×ShÑShÐjnÐ9oÐquÔvØ×4Ñ4×8Ñ8Ø"×,Ñ,¨m×.CÑ.CÀ]×E[ÑE[Ð\Ð^bõð .r>   ÚmodeÚ
block_sizeÚHfFileSystemFilec                 ón   — d|v rt        d«      ‚|dk(  rt        | |f|||dœ|¤ŽS t        | |f|||dœ|¤ŽS )NÚaz/Appending to remote files is not yet supported.r   )r�   r+   r‚   )rc   ÚHfFileSystemStreamFilerƒ   )r:   r[   r�   r+   r‚   Úkwargss         r<   Ú_openzHfFileSystem._open  sX   € ð �$‰;Ü%Ð&WÓXÐXØ˜Š?Ü)¨$°Ðt¸4È(Ð_iÑtÐmsÑtÐtä# D¨$Ðn°TÀHÐYcÑnÐgmÑnÐnr>   c                 óN  — | j                  ||¬«      }| j                  j                  |j                  |j                  | j
                  |j                  |j                  |j                  d«      |j                  d«      ¬«       | j                  |j                  «       ¬«       y )N©r+   Úcommit_messageÚcommit_description)r,   r*   rK   r)   r+   r‹   rŒ   ©r[   )ry   rP   Údelete_filer,   r*   rK   r)   r+   r6   r€   r=   )r:   r[   r+   r‡   r   s        r<   Ú_rmzHfFileSystem._rm  s�   € Ø×)Ñ)¨$¸Ð)ÓBˆØ�	‰	×ÑØ&×3Ñ3Ø!×)Ñ)Ø—*‘*Ø#×-Ñ-Ø"×+Ñ+Ø!Ÿ:™:Ð&6Ó7Ø%Ÿz™zÐ*>Ó?ð 	ô 	
ð 	×Ñ =×#:Ñ#:Ó#<ÐÕ=r>   Ú	recursiveÚmaxdepthc                 óX  — | j                  ||¬«      }| j                  ||||¬«      }|D �cg c]/  }| j                  |«      rŒ| j                  |«      j                  ‘Œ1 }}|D �	cg c]  }	t	        |	¬«      ‘Œ }
}	d› d�}||rdndz  }||�d	|› d�ndz  }| j
                  j                  |j                  |j                  | j                  |
|j                  |j                  d
|«      |j                  d«      ¬«       | j                  |j                  «       ¬«       yc c}w c c}	w )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).

        <Tip warning={true}>

            Note: When possible, use `HfApi.delete_file()` for better performance.

        </Tip>

        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‘   r+   )r,   zDelete ú zrecursively r2   Nzup to depth r‹   rŒ   )r*   r)   rK   Ú
operationsr+   r‹   rŒ   r�   )ry   Úexpand_pathÚisdirr,   r   rP   Úcreate_commitr*   r)   rK   r+   r6   r€   r=   )r:   r[   r�   r‘   r+   r‡   r   ÚpathsÚpaths_in_repor,   r”   r‹   s               r<   ÚrmzHfFileSystem.rm"  s3  € ð< ×)Ñ)¨$¸Ð)ÓBˆØ× Ñ  °ÀXÐX`Ð ÓaˆØJOÖhÀ$ÐW[×WaÑWaÐbfÕWg˜×*Ñ*¨4Ó0×=Ó=ÐhˆÐhØ[hÖiÈ<Ô+¸ÖFÐiˆ
ÐiØ" 4 &¨Ð*ˆØ©I™.¸2Ñ=ˆØ¸Ð8L˜L¨¨
°!Ñ4ÐRTÑTˆà�	‰	×ÑØ!×)Ñ)Ø#×-Ñ-Ø—*‘*Ø!Ø"×+Ñ+Ø!Ÿ:™:Ð&6¸ÓGØ%Ÿz™zÐ*>Ó?ð 	 ô 	
ð 	×Ñ =×#:Ñ#:Ó#<ÐÕ=ùò iùÚis   ­D"ÁD"Á'D'ÚdetailÚrefreshc                 óÂ  — | j                  ||¬«      }|j                  «       }d|i|¥}	  | j                  |f||dœ|¤Ž}|r|S |D �cg c]  }|d   ‘Œ	 c}S # t        $ rx |j                  st        |d«        | j                  | j                  |«      f||dœ|¤Ž}|D �cg c]  }|d   |k(  sŒ|‘Œ nc c}w }}t        |«      dk(  rt        |d«       Y Œ—w xY wc c}w )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).

        <Tip warning={true}>

            Note: When possible, use `HfApi.list_repo_tree()` for better performance.

        </Tip>

        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Š   Úexpand_info)rœ   r+   NÚnamer   )ry   r=   Ú_ls_treer   r,   rn   r~   Úlen)	r:   r[   r›   rœ   r+   r‡   r   ÚoutÚos	            r<   ÚlszHfFileSystem.lsS  sú   € ð: ×)Ñ)¨$¸Ð)ÓBˆØ×&Ñ&Ó(ˆØ Ð2¨6Ð2ˆð		2Ø�$—-‘- ÐS¨gÀÑSÈFÑSˆCñ ˆsÐ:°cÖ":° 1 V£9Ò":Ð:øô "ò 	2à ×-Ò-Ü% d¨DÔ1Ø�$—-‘- §¡¨TÓ 2Ða¸GÈhÑaÐZ`ÑaˆCØ!Ö7˜ Q v¡Y°$Ó%6’1Ñ7ùÒ7ˆCÐ7Ü�3‹x˜1Š}Ü% d¨DÔ1ùð	2üò #;s*   «A Á	CÁA
CÂ"B5Â0B5Â4"CÃCrž   c           	      ó¤  — | j                  ||¬«      }|j                  «       }t        |j                  |j                  |j
                  d|j                  ¬«      j                  «       }g }|| j                  v �r|�s| j                  |   }	|j                  |	«       g }
|r¨t        |	D �cg c]  }|d   dk(  sŒ|‘Œ c}«      }|r„|j                  «       }|d   | j                  vr|
j                  |d   «       nK| j                  |d      }	|j                  |	«       |j                  |	D �cg c]  }|d   dk(  sŒ|‘Œ c}«       |rŒ„g }|r'|D �cg c]  }|d   �Œ	| j                  |d   «      ‘Œ }}|r|
s|�r|�rt        j                  j                  |
|z   «      }|j!                  d«      s||k(  s|t#        |
|«      v r|j%                  d«      n| j                  |«      }|D �cg c]  }|d   j'                  |dz   «      rŒ|‘Œ }}| j                  D ]3  }|j'                  |dz   «      sŒ| j                  j)                  |d «       Œ5 | j                  j)                  |d «       |j                  | j+                  ||d	||¬
«      «       |S | j,                  j/                  |j                  |j0                  |||j
                  |j                  ¬«      }|D ]Û  }t3        |t4        «      rM|dz   |j                  z   |j6                  d|j8                  |j:                  |j<                  |j>                  dœ}n,|dz   |j                  z   dd|j@                  |j<                  dœ}| j                  |d   «      }| j                  jC                  |g «      j                  |«       |j                  |«       ŒÝ |S c c}w c c}w c c}w c c}w )NrŠ   r2   ©r,   r/   ÚtypeÚ	directoryrŸ   Úlast_commitr4   T)r�   rœ   r+   rž   )r�   Úexpandr+   r)   Úfile©rŸ   Úsizer§   Úblob_idÚlfsr©   Úsecurityr   ©rŸ   r­   r§   Útree_idr©   )"ry   r=   r(   r)   r*   r+   r/   r{   Úextendr   ÚpopleftÚappendr~   Úosr[   ÚcommonprefixÚendswithr   r7   Ú
startswithr}   r    rP   Úlist_repo_treer,   rp   r#   r­   r®   r¯   r©   r°   r²   Ú
setdefault)r:   r[   r�   rœ   r+   rž   r   Ú	root_pathr¢   Úcached_path_infosÚdirs_not_in_dircacheÚ	path_infoÚdirs_to_visitÚdir_infoÚdirs_not_expandedr£   Úcommon_prefixÚcommon_pathÚcached_pathÚtreeÚcache_path_infoÚparent_paths                         r<   r    zHfFileSystem._ls_tree  sÚ  € ð ×)Ñ)¨$¸Ð)ÓBˆØ×&Ñ&Ó(ˆÜ,Ø×#Ñ#Ø×!Ñ!Ø×"Ñ"ØØ'×5Ñ5ô
÷ ‰)‹+ð 	ð ˆØ�4—=‘=Ò ªØ $§¡¨dÑ 3ÐØ�J‰JÐ(Ô)Ø#%Ð Ùô !&Ø0AÖf 9ÀYÈvÑEVÐZeÓEe’YÒfó!�ñ $Ø,×4Ñ4Ó6�HØ Ñ'¨t¯}©}Ñ<Ø,×3Ñ3°H¸VÑ4DÕEà,0¯M©M¸(À6Ñ:JÑ,KÐ)ØŸ
™
Ð#4Ô5Ø%×,Ñ,Ø8IÖn¨9ÈYÐW]ÑM^ÐbmÓMmšYÒnôò $ð !#ÐÙàFIÖ$fÀÈQÈ}ÑM]ÑMe T§\¡\°!°F±)Õ%<Ð$fÐ!Ð$fáÑ2ºÒHYô !#§¡× 4Ñ 4Ð5IÐL]Ñ5]Ó ^�ð %×-Ñ-¨cÔ2Ø$¨	Ò1Ø$¬Ð.BÐDUÓ(VÑVð "×(Ñ(¨Ô-ð Ÿ™ mÓ4ð ð #&ÖU˜Q¨Q¨v©Y×-AÑ-AÀ+ÐPSÑBSÕ-T’qÐU�ÐUØ#'§=¡=ò =�KØ"×-Ñ-¨k¸CÑ.?Õ@ØŸ™×)Ñ)¨+°tÕ<ð=ð —‘×!Ñ! +¨tÔ4Ø—
‘
Ø—M‘MØ#Ø"+Ø $Ø!)Ø$/ð "ó ôðP ˆ
ð= —9‘9×+Ñ+Ø×%Ñ%Ø×*Ñ*Ø#Ø"Ø&×/Ñ/Ø'×1Ñ1ð ,ó ˆDð "ò ,�	Ü˜i¬Ô2à )¨C¡°)·.±.Ñ @Ø )§¡Ø &Ø#,×#4Ñ#4Ø(Ÿ}™}Ø'0×'<Ñ'<Ø$-×$6Ñ$6ñ'‘Oð !*¨C¡°)·.±.Ñ @Ø !Ø +Ø#,×#4Ñ#4Ø'0×'<Ñ'<ñ'�Oð #Ÿl™l¨?¸6Ñ+BÓC�Ø—‘×(Ñ(¨°bÓ9×@Ñ@ÀÔQØ—
‘
˜?Õ+ð+,ð, ˆ
ùòW gùò oùò %gùò Vs0   Â+N>Â9N>Ä.OÄ<OÅ
OÅOÇ+OÈOc              /   óÔ   •K  — d|j                  dd«      i|¥}| j                  ||j                  d«      ¬«      j                  «       }t        ‰| �  |g|¢­i |¤ŽE d{  –—†  y7 Œ­w)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.
        rž   r›   Fr+   rŠ   N)r6   ry   r=   rM   Úwalk)r:   r[   rR   r‡   rT   s       €r<   rÊ   zHfFileSystem.walkç  sf   øè ø€ ð   §¡¨H°eÓ!<ÐGÀÐGˆØ× Ñ  °·
±
¸:Ó0FÐ ÓG×QÑQÓSˆÜ‘7‘< Ð6 tÒ6¨vÑ6×6Ò6ús   ƒAA(Á A&Á!A(c                 ó°   •— d|j                  dd«      i|¥}| j                  ||j                  d«      ¬«      j                  «       }t        ‰| �  |fi |¤ŽS )ah  
        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.

        Returns:
            `List[str]`: List of paths matching the pattern.
        rž   r›   Fr+   rŠ   )r6   ry   r=   rM   Úglob)r:   r[   r‡   rT   s      €r<   rÌ   zHfFileSystem.globù  sZ   ø€ ð   §¡¨H°eÓ!<ÐGÀÐGˆØ× Ñ  °·
±
¸:Ó0FÐ ÓG×QÑQÓSˆÜ‰w‰|˜DÑ+ FÑ+Ð+r>   Úwithdirsc           	      óJ  •— |rt        ‰| �  |f|||||dœ|¤ŽS | j                  ||¬«      }|j                  «       }d|i|¥}	  | j                  |fd||j
                  dœ|¤Ž}	|s|	D �
cg c]  }
|
d   dk7  sŒ|
‘Œ }	}
n/ | j                  |fd|j
                  i|¤Ž}|d   dk(  r|g|	z   n|	}	|	D �
ci c]  }
|
d	   |
“Œ
 }	}
t        |	«      }|s|S |D �ci c]  }||	|   “Œ
 c}S c c}
w c c}
w # t        $ r%  | j                  |fd|i|¤Žd   d
k(  r|i i}	ni }	Y ŒZw xY wc c}w )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.
        )r‘   rÍ   r›   rœ   r+   rŠ   rž   T)r�   rœ   r+   r§   r¨   r+   rŸ   r«   )	rM   Úfindry   r=   r    r+   Úinfor   Úsorted)r:   r[   r‘   rÍ   r›   rœ   r+   r‡   r   r¢   r£   r¿   ÚnamesrŸ   rT   s                 €r<   rÏ   zHfFileSystem.find  sŒ  ø€ ñ@ Ü‘7‘<ØðØ'°(À6ÐSZÐemñØqwñð ð ×)Ñ)¨$¸Ð)ÓBˆØ×&Ñ&Ó(ˆØ Ð2¨6Ð2ˆð	.Ø�$—-‘- Ðq°¸gÐP]×PfÑPfÑqÐjpÑqˆCñ Ø"%ÖB˜Q¨¨6©°kÓ)A’qÐB�ÑBð &˜DŸI™I dÑV°]×5KÑ5KÐVÈvÑV�	Ø+4°VÑ+<ÀÒ+K�y�k CÒ'ÐQT�Ø),Ö- A�1�V‘9˜a‘<Ð-ˆCÐ-Ü�s“ˆÙØˆLà05Ö6¨�D˜#˜d™)‘OÒ6Ð6ùò Cùò
 .øô "ò 	àˆt�y‰y˜Ñ;¨Ð;°FÑ;¸FÑCÀvÒMØ˜R�j‘à�ùð	üò$ 7s*   Á!C/ Á+C%Á9C%Â3C*ÃD Ã/+DÄDÚpath1Úpath2c                 óà  — | j                  ||¬«      }| j                  ||¬«      }|j                  |j                  k(  xr |j                  |j                  k(  }|r“d|› d|› �}| j                  j	                  |j                  |j                  |j
                  |j                  d|«      |j                  dd«      t        |j                  |j                  |j
                  ¬«      g¬«       n³| j                  |d	|j
                  ¬«      5 }	|	j                  «       }
d
d
d
«       d|› d|› �}| j                  j                  
|j                  |j                  | j                  |j                  |j
                  |j                  d|«      |j                  d«      ¬«       | j                  |j                  «       ¬«       | j                  |j                  «       ¬«       y
# 1 sw Y   ŒÆxY w)aµ  
        Copy a file within or between repositories.

        <Tip warning={true}>

            Note: When possible, use `HfApi.upload_file()` for better performance.

        </Tip>

        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 z to r‹   rŒ   r2   )Úsrc_path_in_repor,   Úsrc_revision)r*   r)   r+   r‹   rŒ   r”   ÚrbN©Úpath_or_fileobjr,   r*   rK   r)   r+   r‹   rŒ   r�   )ry   r)   r*   rP   r—   r+   r6   r   r,   ÚopenÚreadÚupload_filerK   r€   r=   )r:   rÓ   rÔ   r+   r‡   Úresolved_path1Úresolved_path2Ú	same_repor‹   ÚfÚcontents              r<   Úcp_filezHfFileSystem.cp_fileH  sÔ  € ð& ×*Ñ*¨5¸8Ð*ÓDˆØ×*Ñ*¨5¸8Ð*ÓDˆð ×$Ñ$¨×(@Ñ(@Ñ@ÒuÀ^×E[ÑE[Ð_m×_uÑ_uÑEuð 	ñ Ø$ U G¨4°¨wÐ7ˆNØ�I‰I×#Ñ#Ø&×.Ñ.Ø(×2Ñ2Ø'×0Ñ0Ø%Ÿz™zÐ*:¸NÓKØ#)§:¡:Ð.BÀBÓ#Gä'Ø)7×)DÑ)DØ%3×%@Ñ%@Ø%3×%<Ñ%<ôðð $õ ð —‘˜5 $°×1HÑ1H�ÓIð #ÈQØŸ&™&›(�÷#à$ U G¨4°¨wÐ7ˆNØ�I‰I×!Ñ!Ø 'Ø+×8Ñ8Ø&×.Ñ.Ø—j‘jØ(×2Ñ2Ø'×0Ñ0Ø%Ÿz™zÐ*:¸NÓKØ#)§:¡:Ð.BÓ#Cð "ô 	ð 	×Ñ >×#;Ñ#;Ó#=ÐÔ>Ø×Ñ >×#;Ñ#;Ó#=ÐÕ>÷#ð #ús   ÄG$Ç$G-c                 ó8   —  | j                   |fi |¤Ž}|d   d   S )ai  
        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 commit date of the file.
        r©   Údate©rÐ   )r:   r[   r‡   rÐ   s       r<   ÚmodifiedzHfFileSystem.modifiedƒ  s)   € ð ˆt�y‰y˜Ñ( Ñ(ˆØ�MÑ" 6Ñ*Ð*r>   c                 ó4  — | j                  ||¬«      }|j                  «       }|j                  dd«      }|j                  s}|dddœ}|�r?| j                  j                  |j                  |j                  |j                  ¬«      d   }i |¥d	t        |j                  |j                  |j                  ¬
«      dœ¥}�nËd	}| j                  |«      }	|s!|	| j                  vr| j                  |	d¬«       |	| j                  v r8| j                  |	   D �
cg c]  }
|
d   |k(  sŒ|
‘Œ }}
|st!        |d	«       |d   }|s|�|�rH|�rE|d   �€?| j                  j#                  |j                  |j                  ||j                  |j                  ¬«      }|st!        |d	«       |d   }t%        |j                  |j                  |j                  d|j&                  ¬«      j                  «       }t)        |t*        «      rM|dz   |j,                  z   |j.                  d|j0                  |j2                  |j4                  |j6                  dœ}n,|dz   |j,                  z   dd|j8                  |j4                  dœ}|sdD �ci c]  }|||   “Œ
 }}|€J ‚|S c c}
w c c}w )a  
        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).

        <Tip warning={true}>

            Note: When possible, use `HfApi.get_paths_info()` or `HfApi.repo_info()`  for better performance.

        </Tip>

        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ž   Tr   r¨   )rŸ   r­   r§   )r)   r+   éÿÿÿÿN)ÚoidÚtitlerå   )r²   r©   F©rž   rŸ   r©   )rª   r+   r)   r2   r¦   r4   r«   r¬   r±   )ry   r=   r6   r,   rP   Úlist_repo_commitsr*   r)   r+   r"   Ú	commit_idrë   Ú
created_atr~   r{   r¤   rn   Úget_paths_infor(   r/   rp   r#   r[   r­   r®   r¯   r©   r°   r²   )r:   r[   rœ   r+   r‡   r   rž   r¢   r©   rÈ   r£   Úout1Ú
paths_infor¿   r¼   Úks                   r<   rÐ   zHfFileSystem.info“  s³  € ð0 ×)Ñ)¨$¸Ð)ÓBˆØ×&Ñ&Ó(ˆØ—j‘jØ˜4ó
ˆð ×)Ò)ð ØØ#ñˆCò
 Ø"Ÿi™i×9Ñ9Ø!×)Ñ)°]×5LÑ5LÐWd×WmÑWmð :ó àñ�ðØðà#Ü#1Ø'×1Ñ1¸×9JÑ9JÐQ\×QgÑQgô$ò’ð ˆCØŸ,™, tÓ,ˆKÙ ;°d·m±mÑ#Cà—‘˜°�Ô7Ø˜dŸm™mÑ+à#'§=¡=°Ñ#=ÖS˜aÀÀ6ÁÈdÓARšÐS�ÐSÙÜ)¨$°Ô5Ø˜1‘g�Ù˜#˜+ª+º#À#ÀmÑBTÑB\Ø!ŸY™Y×5Ñ5Ø!×)Ñ)Ø!×.Ñ.Ø&Ø*×3Ñ3Ø+×5Ñ5ð 6ó �
ñ "Ü)¨$°Ô5Ø& q™M�	Ü4Ø!×+Ñ+Ø!×)Ñ)Ø!×*Ñ*Ø!#Ø"/×"=Ñ"=ô÷ ‘)“+ð ô ˜i¬Ô2à )¨C¡°)·.±.Ñ @Ø )§¡Ø &Ø#,×#4Ñ#4Ø(Ÿ}™}Ø'0×'<Ñ'<Ø$-×$6Ñ$6ñ‘Cð !*¨C¡°)·.±.Ñ @Ø !Ø +Ø#,×#4Ñ#4Ø'0×'<Ñ'<ñ�Cñ #Ø.FÖG¨˜1˜c !™f™9ÐG�CÐGØˆÐˆØˆ
ùòW TùòR Hs   ÄJÄ"JÉ;Jc                 óŒ   — 	 |j                  dd«      r| j                  |«        | j                  |fi i |¥ddi¥¤Ž y#  Y y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).

        <Tip warning={true}>

            Note: When possible, use `HfApi.file_exists()` for better performance.

        </Tip>

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

        Returns:
            `bool`: True if file exists, False otherwise.
        rœ   Frž   T)r6   r€   rÐ   )r:   r[   r‡   s      r<   ÚexistszHfFileSystem.exists÷  sP   € ð&	Ø�z‰z˜) UÔ+Ø×%Ñ% dÔ+àˆD�I‰I�dÑ?Ð> Ð>¨¸Ñ>Ò?Øøð	Ùús	   ‚<? ¿Ac                 óT   — 	 | j                  |d¬«      d   dk(  S # t        $ r Y y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.
        Frì   r§   r¨   )rÐ   ÚOSError©r:   r[   s     r<   r–   zHfFileSystem.isdir  s6   € ð	Ø—9‘9˜T¨u�9Ó5°fÑ=ÀÑLÐLøÜò 	Ùð	ús   ‚ ›	'¦'c                 óD   — 	 | j                  |d¬«      d   dk(  S #  Y y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.
        Frì   r§   r«   ræ   rø   s     r<   ÚisfilezHfFileSystem.isfile%  s.   € ð	Ø—9‘9˜T¨u�9Ó5°fÑ=ÀÑGÐGøð	Ùús   ‚ ›c                 óô   — | j                  |«      }t        |j                  |j                  |j                  |j
                  | j                  ¬«      }| j                  |«      r|j                  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.
        )r)   r+   rJ   z	/resolve/z/tree/r   )	ry   r   r*   r,   r)   r+   rJ   r–   Úreplace)r:   r[   r   Úurls       r<   rý   zHfFileSystem.url7  sn   € ð ×)Ñ)¨$Ó/ˆÜØ×!Ñ!Ø×&Ñ&Ø#×-Ñ-Ø"×+Ñ+Ø—]‘]ô
ˆð �:‰:�dÔØ—+‘+˜k¨8°QÓ7ˆCØˆ
r>   c                 ó  •— |j                  d«      }t        |j                  «       «      dhz
  }t        |t        t
        f«      rt        |«      dkD  rt        ‰| �   ||f||dœ|¤ŽS t        |«      r|}n)| j                  |«      rt        j                  |d¬«       yt        |t        t        f«      r4t        j                  t        j                  j!                  |«      d¬«       d}|€t#        |d«      }d}|j%                  «       }	| j'                  ||¬	«      }
| j)                  ||¬	«      d
   }|j+                  |«       	 t-        t/        |
j0                  |
j2                  |
j4                  |
j6                  | j8                  ¬«      |||d| j:                  j=                  «       t        |t
        «      r|j>                  nd¬«       |jA                  |	«       |r|jC                  «        yy# |r|jC                  «        w w xY w)a^  
        Copy single remote file to local.

        <Tip warning={true}>

            Note: When possible, use `HfApi.hf_hub_download()` for better performance.

        </Tip>

        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.

        r+   r   )ÚcallbackÚoutfileT)Úexist_okNFÚwbrŠ   r­   ©r*   r+   Úfilenamer)   rJ   )rý   Ú	temp_fileÚdisplayed_filenameÚexpected_sizeÚresume_sizeÚheadersÚ	_tqdm_bar)"r6   ÚsetÚkeysrp   r   r   r¡   rM   Úget_filer   r–   r¶   ÚmakedirsrC   r   r[   ÚdirnamerÛ   Útellry   rÐ   Úset_sizer    r   r*   r+   r,   r)   rJ   rP   Ú_build_hf_headersÚtqdmÚseekÚclose)r:   ÚrpathÚlpathrÿ   r   r‡   r+   Úunhandled_kwargsÚ
close_fileÚinitial_posÚresolve_remote_pathr  rT   s               €r<   r  zHfFileSystem.get_fileN  sÇ  ø€ ð* —:‘:˜jÓ)ˆÜ˜vŸ{™{›}Ó-°°Ñ<ÐÜ˜(¤\´<Ð$@ÔAÄSÐIYÓEZÐ]^ÒE^ô ‘7Ñ# E¨5Ð_¸8ÈWÑ_ÐX^Ñ_Ð_ô �eÔØ‰GØ�Z‰Z˜ÔÜ�K‰K˜¨Õ-Øä�eœc¤4˜[Ô)Ü�K‰KœŸ™Ÿ™¨Ó.¸Õ>ð ˆ
Øˆ?Ü˜5 $Ó'ˆGØˆJØ—l‘l“nˆð #×/Ñ/°ÀÐ/ÓIÐØŸ	™	 %°(˜	Ó;¸FÑCˆØ×Ñ˜-Ô(ð	 ÜÜØ/×7Ñ7Ø0×9Ñ9Ø0×=Ñ=Ø1×;Ñ;Ø!Ÿ]™]ôð "Ø#(Ø+ØØŸ	™	×3Ñ3Ó5Ü+5°hÄÔ+M˜(Ÿ-š-ÐSWõð �L‰L˜Ô%ñ Ø—‘•ð ø‰zØ—‘•ð ús   ÅBG1 Ç1H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.©rc   ©r:   s    r<   ÚtransactionzHfFileSystem.transaction•  s   € ô "Ð"LÓMÐMr>   c                 ó   — t        d«      ‚)z@Begin write transaction for deferring files, non-context versionr  r  r  s    r<   Ústart_transactionzHfFileSystem.start_transaction   s   € ô "Ð"LÓMÐMr>   ©N)rØ   NN)FNN)TFN)FFNT)NFFFN)FN©r0   N),r?   r@   rA   rB   Úroot_markerÚprotocolr   rC   r   ÚboolrN   r   Ú	ExceptionrZ   r(   ry   r€   Úintrˆ   r�   rš   r   r
   r	   r¤   r    r   rÊ   rÌ   rÏ   rã   r   rç   rÐ   rõ   r–   rú   rý   r   r  Úpropertyr   r"  Ú__classcell__©rT   s   @r<   rG   rG   :   s�  ø„ ñ&ðP €KØ€Hð
 #'Ø(,ò	ð ˜3‘-ðð �T˜3 �_Ñ%õ	ð$TØðTØ'*ðTØ6>¸s±mðTà	ˆt�X˜iÑ(Ð(Ñ	)óTñ&]t ð ]t°¸±ð ]tÐIaó ]tñ~ X¨c¡]ð ¸dó ð> Ø"&Ø$(ñoàðoð ðoð ˜3‘-ð	oð
 ˜S‘Mðoð 
óoñ>˜ð > x°¡}ð >È$ó >ð   Ø"&Ø"&ñ/>àð/>ð ð/>ð ˜3‘-ð	/>ð
 ˜3‘-ð/>ð 
ó/>ðd `dñ*;Øð*;Ø!%ð*;Ø7;ð*;ØOWÐX[É}ð*;à	ˆe�C˜˜c 3˜h™Ð'Ñ(Ñ	)ó*;ð^  ØØ"&Ø ñfàðfð ðfð ð	fð
 ˜3‘-ðfð ófðP7˜ð 7°(¸5ÀÀdÈ3ÁiÐQUÐVYÑQZÐAZÑ;[Ñ2\õ 7ð$,˜ð ,¨4°©9õ ,ð* #'ØØØØ"&ñ;7àð;7ð ˜3‘-ð;7ð ð	;7ð
 ð;7ð ð;7ð ˜3‘-ð;7ð 
ˆt�C‰y˜$˜s D¨¨c¨¡NÐ2Ñ3Ð3Ñ	4õ;7ñz9?˜Sð 9?¨ð 9?¸À¹ð 9?Ð[_ó 9?ðv+˜Sð +¨xó +ñ b˜ð b tð b¸xÈ¹}ð bÐbfÐgjÐloÐgoÑbpó bòHò8ò$ð$˜ð  ó ð. /@Èö E ðN ñNó ðNöNr>   rG   c                   ó„   ‡ — e Zd Zddededee   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Úfsr[   r+   c                 ó‚  •— 	 |j                  ||¬«      | _        |j                  dd«      dk(  r0|j	                  | j                  j                  «       d¬«      | _        t        ‰| �   || j                  j                  «       fi |¤Ž |  y # t        $ r)}d|j                  dd«      v rt        |› d�«      |‚‚ d }~ww xY w)	NrŠ   Úwr�   r2   úB.
Make sure the repository and revision exist before writing data.rØ   Frì   )	ry   r   ÚFileNotFoundErrorr6   rÐ   r=   ÚdetailsrM   rN   )r:   r.  r[   r+   r‡   rY   rT   s         €r<   rN   zHfFileSystemFile.__init__¨  sÀ   ø€ ð	Ø!#§¡°À Ó!IˆDÔð �:‰:�f˜dÓ# tÒ+ØŸ7™7 4×#5Ñ#5×#?Ñ#?Ó#AÈu˜7ÓUˆDŒLÜ‰Ñ˜˜T×/Ñ/×9Ñ9Ó;ÑF¸vÒFÚøô !ò 	Ø�f—j‘j ¨Ó,Ñ,Ü'Ø�cÐ\Ð]óàðð ûð	ús   ƒB Â	B>Â$B9Â9B>c                 ó:   •— t        | d«      sy t        ‰| �	  «       S ©Nr   ©ÚhasattrrM   Ú__del__©r:   rT   s    €r<   r8  zHfFileSystemFile.__del__·  ó   ø€ Ü�t˜_Ô-àÜ‰w‰Ó Ð r>   ÚstartÚendr0   c                 ó¶  — dd|› d|dz
  › �i| j                   j                  j                  «       ¥}t        | j                  j
                  | j                  j                  | j                  j                  | j                  j                  | j                   j                  ¬«      }t        d||dt        j                  ¬«      }t        |«       |j                  S )	NÚrangezbytes=ú-r   r  ÚGET©iô  iö  i÷  iø  )r	  Úretry_on_status_codesrV   )r.  rP   r  r   r   r*   r+   r,   r)   rJ   r&   r   ÚHF_HUB_DOWNLOAD_TIMEOUTr%   râ   )r:   r;  r<  r	  rý   Úrs         r<   Ú_fetch_rangezHfFileSystemFile._fetch_range½  sÂ   € à�v˜e˜W A c¨A¡g YÐ/ð
à�g‰g�l‰l×,Ñ,Ó.ð
ˆô Ø×&Ñ&×.Ñ.Ø×'Ñ'×0Ñ0Ø×'Ñ'×4Ñ4Ø×(Ñ(×2Ñ2Ø—W‘W×%Ñ%ô
ˆô ØØØØ"6Ü×5Ñ5ô
ˆô 	˜AÔØ�y‰yÐr>   c                 ó<   — t        j                  dd¬«      | _        y )Nzhffs-F)ÚprefixÚdelete)ÚtempfileÚNamedTemporaryFiler  r  s    r<   Ú_initiate_uploadz!HfFileSystemFile._initiate_uploadÓ  s   € Ü!×4Ñ4¸GÈEÔRˆ�r>   Úfinalc                 óH  — | j                   j                  d«       | j                   j                  «       }| j                  j	                  |«       |�rO| j                  j                  «        | j                  j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                   j#                  d«      | j                   j#                  d«      ¬«       t%        j&                  | j                  j                  «       | j                  j)                  | j                  j+                  «       ¬«       y y )Nr   r‹   rŒ   rÙ   r�   )Úbufferr  rÜ   r  Úwriter  r.  rP   rÝ   rŸ   r   r,   r*   rK   r)   r+   r‡   r6   r¶   Úremover€   r=   )r:   rL  Úblocks      r<   Ú_upload_chunkzHfFileSystemFile._upload_chunkÖ  s"  € Ø�‰×Ñ˜ÔØ—‘× Ñ Ó"ˆØ�‰×Ñ˜UÔ#ÚØ�N‰N× Ñ Ô"Ø�G‰G�L‰L×$Ñ$Ø $§¡× 3Ñ 3Ø!×/Ñ/×<Ñ<Ø×*Ñ*×2Ñ2Ø—g‘g—m‘mØ×,Ñ,×6Ñ6Ø×+Ñ+×4Ñ4Ø#Ÿ{™{Ÿ™Ð/?Ó@Ø#'§;¡;§?¡?Ð3GÓ#Hð %ô 	ô �I‰I�d—n‘n×)Ñ)Ô*Ø�G‰G×$Ñ$Ø×'Ñ'×1Ñ1Ó3ð %õ ð r>   c                 ó  •— | j                   dk(  rX|�|dk(  rQ| j                  dk(  rB| j                  j                  | j                  dd¬«      5 }|j                  «       cddd«       S t        ‰| �  |«      S # 1 sw Y   ŒxY w)a)  Read remote file.

        If `length` is not provided or is -1, the entire file is downloaded and read. On POSIX systems and if
        `hf_transfer` is not enabled, the file is loaded in memory directly. Otherwise, the file is downloaded to a
        temporary file and read from there.
        rØ   Nré   r   )r‚   )r�   Úlocr.  rÛ   r[   rÜ   rM   )r:   Úlengthrá   rT   s      €r<   rÜ   zHfFileSystemFile.readë  st   ø€ ð �9‰9˜Ò & .°F¸b²LÀdÇhÁhÐRSÂmØ—‘—‘˜dŸi™i¨¸!�Ó<ð  ÀØ—v‘v“x÷ ñ  ä‰w‰|˜FÓ#Ð#÷ ð  ús   ÁA8Á8Bc                 óL   — | j                   j                  | j                  «      S r#  ©r.  rý   r[   r  s    r<   rý   zHfFileSystemFile.url÷  ó   € Ø�w‰w�{‰{˜4Ÿ9™9Ó%Ð%r>   r#  r$  )F©ré   )r?   r@   rA   rG   rC   r   rN   r8  r)  ÚbytesrE  rK  r'  rR  rÜ   rý   r+  r,  s   @r<   rƒ   rƒ   §  sj   ø„ ñ˜<ð ¨sð ¸hÀs¹mõ ô!ð #ð ¨Cð °Eó ó,Sñ 4ð °Dó õ*
$ð&�S÷ &r>   rƒ   c                   ó„   ‡ — e Zd Z	 	 	 	 ddedededee   dedefˆ fd„Zdded	efd
„Zddefd„Z	defd„Z
ˆ fd„Zd„ Zˆ xZS )r†   r.  r[   r�   r+   r‚   Ú
cache_typec                 óÌ  •— |dk7  rt        d|› �«      ‚|dk7  rt        d|› �«      ‚d|v rt        d|› d�«      ‚	 |j                  ||¬«      | _        | j                  j                  «       d dœ| _        t        ‰	| �   || j                  j                  «       f|||dœ|¤Ž d | _	        |  y # t        $ r-}d|j	                  d	d
«      v rt        |› d�«      |‚Y d }~ŒŠd }~ww xY w)Nr   z:HfFileSystemStreamFile only supports block_size=0 but got Únonez?HfFileSystemStreamFile only supports cache_type='none' but got r0  z;HfFileSystemStreamFile only supports reading but got mode='ú'rŠ   r�   r2   r1  )rŸ   r­   ©r�   r‚   r\  )
r_   ry   r   r2  r6   r=   r3  rM   rN   Úresponse)
r:   r.  r[   r�   r+   r‚   r\  r‡   rY   rT   s
            €r<   rN   zHfFileSystemStreamFile.__init__ü  s  ø€ ð ˜Š?ÜÐYÐZdÐYeÐfÓgÐgØ˜ÒÜÐ^Ð_iÐ^jÐkÓlÐlØ�$‰;ÜÐZÐ[_ÐZ`Ð`aÐbÓcÐcð	Ø!#§¡°À Ó!IˆDÔð !%× 2Ñ 2× <Ñ <Ó >ÈÑMˆŒÜ‰ÑØ�×"Ñ"×,Ñ,Ó.ð	
Ø59ÀjÐ]gñ	
Økqò	
ð -1ˆŒÚøô !ò 	Ø�f—j‘j ¨Ó,Ñ,Ü'Ø�cÐ\Ð]óàðô -ûð	ús   ¼B- Â-	C#Â6#CÃC#rT  Úwhencec                 óX   — |dk(  r|dk(  ry || j                   k(  r|dk(  ry t        d«      ‚)Nr   r   zCannot seek streaming HF file)rT  r_   )r:   rT  rb  s      r<   r  zHfFileSystemStreamFile.seek  s2   € Ø�!Š8˜ !šØØ�$—(‘(Š?˜v¨š{ØÜÐ8Ó9Ð9r>   rU  c           	      óL  — |dk\  r|fnd}| j                   �$| j                   j                  j                  «       rÏt        | j                  j
                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  ¬«      }t        d|| j                  j                  j                  «       ddt        j                  ¬«      | _         t!        | j                   «       	  | j                   j                  j"                  |Ž }| xj(                  t+        |«      z  c_        |S # t$        $ �rK | j                   j'                  «        t        | j                  j
                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  ¬«      }t        d|dd	| j(                  z  i| j                  j                  j                  «       ¥ddt        j                  ¬«      | _         t!        | j                   «       	  | j                   j                  j"                  |Ž }n(# t$        $ r | j                   j'                  «        ‚ w xY wY �Œtw xY w)
Nr   rE   r  r@  rA  T)r	  rB  ÚstreamrV   ÚRangez	bytes=%d-)ra  ÚrawÚisclosedr   r   r*   r+   r,   r)   r.  rJ   r&   rP   r  r   rC  r%   rÜ   r(  r  rT  r¡   )r:   rU  Ú	read_argsrý   r¢   s        r<   rÜ   zHfFileSystemStreamFile.read"  s  € Ø!'¨1¢�V‘I°"ˆ	Ø�=‰=Ð  D§M¡M×$5Ñ$5×$>Ñ$>Ô$@ÜØ×*Ñ*×2Ñ2Ø×+Ñ+×4Ñ4Ø×+Ñ+×8Ñ8Ø×,Ñ,×6Ñ6ØŸ™×)Ñ)ôˆCô )ØØØŸ™Ÿ™×6Ñ6Ó8Ø&:ØÜ!×9Ñ9ôˆDŒMô   §¡Ô.ð	Ø(�$—-‘-×#Ñ#×(Ñ(¨)Ð4ˆCð4 	�Š”C˜“HÑ�Øˆ
øô5 ó 	Ø�M‰M×ÑÔ!ô Ø×*Ñ*×2Ñ2Ø×+Ñ+×4Ñ4Ø×+Ñ+×8Ñ8Ø×,Ñ,×6Ñ6ØŸ™×)Ñ)ôˆCô )ØØØ  +°·±Ñ"8Ð]¸D¿G¹G¿L¹L×<ZÑ<ZÓ<\Ð]Ø&:ØÜ!×9Ñ9ôˆDŒMô   §¡Ô.ðØ,�d—m‘m×'Ñ'×,Ñ,¨iÐ8‘øÜò Ø—‘×#Ñ#Ô%Øðúò ð+	ús+   Ä#E ÅDJ#É#I7É6J#É7%JÊJ#Ê"J#r0   c                 óL   — | j                   j                  | j                  «      S r#  rW  r  s    r<   rý   zHfFileSystemStreamFile.urlS  rX  r>   c                 ó:   •— t        | d«      sy t        ‰| �	  «       S r5  r6  r9  s    €r<   r8  zHfFileSystemStreamFile.__del__V  r:  r>   c                 ó”   — t         | j                  | j                  | j                  | j                  | j
                  j                  ffS r#  )Úreopenr.  r[   r�   Ú	blocksizeÚcacherŸ   r  s    r<   Ú
__reduce__z!HfFileSystemStreamFile.__reduce__\  s0   € Ü˜Ÿ™ §¡¨D¯I©I°t·~±~ÀtÇzÁzÇÁÐWÐWÐWr>   )rØ   Nr   r^  )r   rY  )r?   r@   rA   rG   rC   r   r)  rN   r  rÜ   rý   r8  rp  r+  r,  s   @r<   r†   r†   û  s‹   ø„ ð
 Ø"&ØØ ñàðð ðð ð	ð
 ˜3‘-ðð ðð õñ>:˜ð : Só :ñ/˜3ó /ðb&�Só &ô!öXr>   r†   r+   r0   c                 óF   — t         j                  | «      r| S t        | «      S r#  )ri   rq   Ú
safe_quoterŠ   s    r<   r9   r9   `  s    € Ü2×8Ñ8¸ÔBˆ8Ð\Ì
ÐS[ÓH\Ð\r>   Úsc                 ó   — t        | d¬«      S )Nr2   )Úsafe)r   )rs  s    r<   rr  rr  d  s   € Ü�˜ÔÐr>   r[   rs   c                 ó    — | }t        |t        «      r| › d�}n+t        |t        «      r| › d�}nt        |t        «      r| › d�}t	        |«      |‚)Nz (repository not found)z (revision not found)z (invalid repository id))rp   r   r   r$   r2  )r[   rs   Úmsgs      r<   rn   rn   h  s\   € Ø
€CÜ�#Ô.Ô/Ø�Ð-Ð.‰Ü	�CÔ.Ô	/Ø�Ð+Ð,‰Ü	�CÔ*Ô	+Ø�Ð.Ð/ˆÜ
˜CÓ
  cÐ)r>   r.  r�   r‚   r\  c                 ó,   — | j                  ||||¬«      S )Nr`  )rÛ   )r.  r[   r�   r‚   r\  s        r<   rm  rm  s  s   € Ø�7‰7�4˜d¨zÀjˆ7ÓQÐQr>   )Gr¶   ÚrerI  Úcollectionsr   Údataclassesr   r   r   Ú	itertoolsr   Úpathlibr   Útypingr	   r
   r   r   r   r   r   r   Úurllib.parser   r   ÚfsspecÚfsspec.callbacksr   r   r   Úfsspec.utilsr   Úrequestsr   r2   r   Ú_commit_apir   r   Úerrorsr   r   r   Úfile_downloadr   r    Úhf_apir!   r"   r#   Úutilsr$   r%   r&   ÚcompileÚVERBOSEri   r(   ÚAbstractFileSystemrG   ÚspecÚAbstractBufferedFilerƒ   r†   rC   r9   rr  r(  rn   r)  rm  rE   r>   r<   ú<module>rŽ     sR  ðÛ 	Û 	Û Ý ß (Ý Ý Ý ß N× NÓ Nß 'ã ß JÑ JÝ #Ý å ß Cß VÑ Vß /ß 3Ñ 3ß GÑ Gð )˜bŸj™jðð
 ‡J�JóÐ ð ÷Bð Bó ðBô*jN�6×,Ñ,ô jNôZQ&�v—{‘{×7Ñ7ô Q&ôhbX˜VŸ[™[×=Ñ=ô bXðJ]˜Cð ] Có ]ð�#ð ˜#ó ð* ð *¨(°9Ñ*=ð *À(ó *ðRˆ|ð R 3ð R¨cð R¸sð RÐPSô Rr>   