+
    &j                       a  R. tW0 t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHtHtHt ^ RIHtHt ^ RIt^ RIt^ RIH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t& ^RI'H(t( ^RI)H*t*H+t+ ^RI,H-t-H.t.H/t/H0t0H1t1 ^RI2H3t3H4t4 ^RI5H6t6H7t7H8t8H9t9H:t:H;t;H<t< ^RI=H>t>H?t?H@t@HAtAHBtB ^RICHDtD ] ! R R4      4       tE] ! R R]E4      4       tF] ! R R]E4      4       tG]H! ]P                  4      tJ] ^ k  ! R R]J4      tK ! R R]P                  ]KR 7      tL ! R! R"]P                  P                  4      tO ! R# R$]P                  P                  4      tPR% R& ltQR' R( ltRR) R* ltSR+ R, ltTR- tU]L! 4       tVR# )/    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                   B   a  ] tR t^$t o RtV 3R lR ltV 3R ltRtV tR# )HfFileSystemResolvedPathz_Top level Data structure containing information about a resolved Hugging Face file system path.c                    < V ^8  d   QhRS[ /#    returnstr)format__classdict__s   "v/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/huggingface_hub/hf_file_system.py__annotate__%HfFileSystemResolvedPath.__annotate__+   s     6 63 6    c                V    V P                    R V P                   2P                  R 4      # )/)rootpathrstripselfs   &r9   	unresolve"HfFileSystemResolvedPath.unresolve+   s&    ))Adii[)0055r<   c                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )r3   r?   r@   r5   )r7   r8   s   "r9   r:   r;   $   s      I	 
 I r<    N)	__name__
__module____qualname____firstlineno____doc__rD   __annotate_func____static_attributes____classdictcell__r8   s   @r9   r0   r0   $   s     i
6 6  r<   r0   c                   n   a  ] tR t^/t o Rt]! RR7      t]! RR7      t]! RRR7      tR t	V 3R lt
RtV tR# )	"HfFileSystemResolvedRepositoryPathzLData structure containing information about a resolved path in a repository.FinitN)defaultreprc                z   \         P                  P                  V P                  R 4      V P                  ,           pV P
                  '       d   V RV P
                   2V n        MEV P                  \         P                  8w  d!   V R\        V P                  4       2V n        MWn        V P                  V n        R# ) @N)r   REPO_TYPES_URL_PREFIXESget	repo_typerepo_id_raw_revisionr?   revisionDEFAULT_REVISIONsafe_revisionpath_in_repor@   )rC   	repo_paths   & r9   __post_init__0HfFileSystemResolvedRepositoryPath.__post_init__=   s    5599$.."MPTP\P\\	$+Qt'9'9&:;DI]]i888$+Q}T]]'C&DEDI!I%%	r<   c                |   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ R,          ;R&   # )	r3   r\   r]   r_   rb   r?   r@   Nr^   r5   )r7   r8   s   "r9   r:   /HfFileSystemResolvedRepositoryPath.__annotate__/   sa      N	 
 L  M    !  !  :? r<   )r@   r?   )rH   rI   rJ   rK   rL   r	   r?   r@   r^   rd   rM   rN   rO   rP   s   @r9   rR   rR   /   s8     V 5!D5!D !&d ?M&  r<   rR   c                   H   a  ] tR t^Ht o Rt]! RR7      tR tV 3R ltRt	V t
R# )HfFileSystemResolvedBucketPathzHData structure containing information about a resolved path in a bucket.FrS   c                6    R V P                   ,           V n        R# )zbuckets/N)	bucket_idr?   rB   s   &r9   rd   ,HfFileSystemResolvedBucketPath.__post_init__O   s    /	r<   c                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )r3   rk   r?   r5   )r7   r8   s   "r9   r:   +HfFileSystemResolvedBucketPath.__annotate__H   s      N	 
 ! r<   )r?   N)rH   rI   rJ   rK   rL   r	   r?   rd   rM   rN   rO   rP   s   @r9   ri   ri   H   s      R 5!D0  r<   ri   c                   <   a a ] tR t^Wt oRtV 3R ltR tRtVtV ;t	# )_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                6   < \         SV `  ! V/ VB  / V n        R # N)super__init___cache)clsargskwargs	__class__s   &*,r9   rt   _Cached.__init__g   s    $)&) 
r<   c                   \        W4      pVP                  R R4      pV P                  ! V \        P                  ! 4       .VO5/ VB pV P                  ! V \        P
                  ! 4       P                  .VO5/ VB pV'       g<   V P                  '       d*   W@P                  9   d   W@n	        V P                  V,          # \        P                  ! V .VO5/ VB pV'       gi   V P                  '       dW   WPP                  9   dG   V P                  V,          P                  4       pVP                  4        F  w  r\        WhV	4       K  	  WFn        Wn        W&n        V P                  '       d   V'       g   W@n	        W`P                  V&   V# )skip_instance_cacheF)r   pop	_tokenize	threading	get_identmain_threadidentcachableru   _latesttype__call___get_instance_stateitemssetattr
_fs_token_storage_argsstorage_options)
rv   rw   rx   skipfs_tokenfs_token_main_threadobjinstance_stateattrstate_values
   &*,       r9   r   _Cached.__call__o   s0    c*zz/7==i&9&9&;MdMfM"}}S)2G2G2I2O2OaRVaZ`aZZ)?"K::h'' --5d5f5CCLLL-AZZ-O!$,@!A!U!U!W)7)=)=)?%DC{3 *@%N#"(|||D&'*

8$Jr<   rG   )
rH   rI   rJ   rK   rL   rt   r   rN   rO   __classcell__ry   r8   s   @@r9   rp   rp   W   s      r<   rp   c                   8  a a ] tR t^t oRtRtRtRRRRRRRR/V3R	 lV 3R
 lllt]V3R lR l4       t	V3R lR lt
V3R lR ltR9V3R lR lltR9V3R lR lltR:V3R lR lltR9V3R lR lltR;V3R lR lltR<V3R lR lltR=V3R lR lltV3R lR  ltV3R! lV 3R" lltR9V3R# lV 3R$ llltR>V3R% lR& lltR9V3R' lR( lltV3R) lR* ltR?V3R+ lR, lltR- tR. tR/ tV3R0 lR1 lt]R3V3R2 lV 3R3 lllt] R4 4       t!R5 t"R6 t#R7 t$R8t%Vt&V ;t'# )@HfFileSystema	  
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)
```
rX   hfendpointNtoken
block_sizeexpand_infoc          	      z   < V ^8  d   QhRS[ R,          RS[S[ ,          R,          RS[R,          RS[R,          /# )r3   r   Nr   r   r   r6   boolint)r7   r8   s   "r9   r:   HfFileSystem.__annotate__   sJ     < < *< czD 	<
 $J< D[<r<   c                  < \         SV `  ! V/ VB  T;'       g    \        P                  V n        W n        \        WR 7      V n        W0n        W@n	        / V n
        / V n        / V n        R# ))r   r   N)rs   rt   r   ENDPOINTr   r   r%   _apir   r   _repo_and_revision_exists_cache_bucket_exists_cachedircache)rC   r   r   r   r   rw   r   ry   s   &$$$$*,r9   rt   HfFileSystem.__init__   se     	$2/2 66I$6$6
89	$& rt,NP! :<r<   c                &   < V ^8  d   QhRS[ RS[/# )r3   threading_identr4   )r   r6   )r7   r8   s   "r9   r:   r      s     	 	 	 	r<   c                8   VP                  R4      ;'       g    \        P                  VR&   VP                  R4      VR&   \        V4       Uu/ uF  qDW4,          bK  	  ppWW#3p\	        \        V4      P                  4       4      pVP                  4       # u upi )zDeterministic token for cachingr   r   )r[   r   r   sortedr.   r6   encode	hexdigest)rv   r   rw   rx   keytokenize_argshs   &&*,   r9   r~   HfFileSystem._tokenize   s     $ZZ
3IIy7I7Iz **W-w.4Vn=nsv{"n=t<M"))+,{{}	 >s   Bc                d   < V ^8  d   QhRS[ RS[ RS[ R,          RS[S[S[R,          3,          /# )r3   r\   r]   r_   Nr4   r6   tupler   	Exception)r7   r8   s   "r9   r:   r      sF     T TT'*T69DjT	tY%%	&Tr<   c                   WV3V P                   9  dP    V P                  P                  W#V\        P                  R 7       RV P                   WV3&   RV P                   WR3&   V P                   WV3,          #   \
        \        3 d1   pRT3T P                   YT3&   RT3T P                   YR3&    Rp?LQRp?i\         d/   pRT3T P                   YT3&   RT P                   YR3&    Rp?LRp?ii ; i))r_   r\   timeoutNFTN)r   r   	repo_infor   HF_HUB_ETAG_TIMEOUTr   r)   r   )rC   r\   r]   r_   es   &&&& r9   _repo_and_revision_exist%HfFileSystem._repo_and_revision_exist   s    )1U1UU^		##)YMjMj $  Xb44i(5STS]44i$5OP33Y4RSS ,->? \W\^_W_44i(5STSXZ[S[44i$5OP( ^W\^_W_44i(5STS]44i$5OP^s)   ,A8 8C0	&B44C0C0$C++C0c                J   < V ^8  d   QhRS[ RS[S[S[R,          3,          /# )r3   rk   r4   Nr   )r7   r8   s   "r9   r:   r   
  s*     4 4 4dI<L6L0M 4r<   c                    WP                   9  d,    V P                  P                  V4       RV P                   V&   V P                   V,          #   \         d   pRT3T P                   T&    Rp?L4Rp?ii ; i)TNFr   )r   r   bucket_infor   )rC   rk   r   s   && r9   _bucket_existsHfFileSystem._bucket_exists
  sr    555B		%%i0 8B)))4((33	 ' @7<ax)))4@s   A A5A00A5c                J   < V ^8  d   QhRS[ RS[ R,          RS[S[,          /# r3   r@   r_   Nr4   )r6   rR   ri   )r7   r8   s   "r9   r:   r     s4     M
 M
M
#&:M
	+.L	LM
r<   c                4   V P                  V4      pV'       g   \        R4      hVP                  R4      ^ 8X  d   \        RV R24      h\	        \
        P                   V 24      pVP                  '       dR   V P                  VP                  4      w  rEV'       g   \        W4       \        VP                  VP                  R7      # VEe   VP                  e   VP                  V8w  d   VP                  R4      ^ ,          \
        P                  9   d   VP                  R^4      ^,          MTpVP                  R^4      w  rxRV9   d   VP                  R^4      MVR3w  r\!        V	4      pW8w  d   \        R	V R
V R24      hV P#                  VP$                  Wr4      w  rV'       g   \        W4       \'        VP$                  WrWR7      # VP                  e   Vf   VP                  pV P#                  VP$                  VP                  V4      w  rV'       g   \        W4       RpRV9   d   VP                  e   VP                  R4      ^ ,          \
        P                  9   d   VP                  R^4      ^,          MTpVP                  R^4      ^,          pVP                  '       d!   VR\)        VP                  4      ^,           )  MTpVe   TM\
        P*                  p\'        VP$                  VP                  W#P                  VR7      # )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.r>   z-Repository id must be 'namespace/name', got 'z<'. Single-segment ids (e.g. 'gpt2') are no longer supported.)rk   r@   NrY   rX   zRevision specified in path ("z ") and in `revision` argument ("z") are not the same.)r^   )_strip_protocolNotImplementedErrorcount
ValueErrorr-   r   HF_PROTOCOL	is_bucketr   id_raise_file_not_foundri   rb   r_   splitHF_URI_TYPE_PREFIXESr   r   r   rR   lenr`   )rC   r@   r_   parsedbucket_existserrpath_without_typer]   after_atrevision_in_pathrb   revision_in_path_decodedrepo_and_revision_existraw_revisionraw_after_ats   &&&            r9   resolve_pathHfFileSystem.resolve_path  s   * ##D)%&dee::c?a?v  FB  C  !6!6 7v>? !%!4!4VYY!?M %d01FIIFL_L_`` FOO$?FOOW_D_
 :>C9KyOmOm9m

3 21 5sw 1 7 7Q ?GGJhX^^C-C]egi\j*'./?'@$'3 34L3MMmnvmw  xL  M  ,0+H+HV]+h(#*%d05W  ??&8+;H'+'D'DV[[RXR[R[]e'f$&!$, $($;6??69=C9KyOmOm9m

3 21 5sw,223:1=LNTNaNaNa<(IC0C0C,Dq,H*IJgsL'389S9S1KKH.A.AQ]
 	
r<   c                2   < V ^8  d   QhRS[ R,          RR/# )r3   r@   Nr4   r5   )r7   r8   s   "r9   r:   r   c  s#     Q QS4Z Q4 Qr<   c                   V'       g7   V P                   P                  4        V P                  P                  4        R# V P                  V4      pVP	                  4       pV'       d0   V P                   P                  VR4       V P                  V4      pK7  VP                  '       g   \        V\        4      '       ds   V P                  P                  VP                  VP                  R3R4       V P                  P                  VP                  VP                  VP                  3R4       R# V P                  P                  VP                  R4       R# R# )a3  
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   rD   r}   _parentr@   
isinstancerR   r\   r]   r_   r   rk   )rC   r@   resolved_paths   && r9   invalidate_cacheHfFileSystem.invalidate_cachec  s    MM!00668 --d3M **,D!!$-||D) !%%%m-OPP88<<&00-2G2GNPT 88<<&00-2G2GI_I_`bf --11-2I2I4P &r<   c                b   < V ^8  d   QhRS[ RS[ RS[R,          RS[ R,          RS[R,          /# )r3   r@   moder   Nr_   r4   )HfFileSystemFileHfFileSystemStreamFile)r6   r   r   )r7   r8   s   "r9   r:   r     sR     X XX X $J	X
 *X 
;	<Xr<   c                    Ve   TMV P                   pVe   W5R&   RV9   d   \        R4      hV^ 8X  d   \        W3RVRV/VB # \        W3RVRV/VB # )Nr   az/Appending to remote files is not yet supported.r   r_   )r   r   r   r   )rC   r@   r   r   r_   rx   s   &&&&&,r9   _openHfFileSystem._open  sr     $.#9Zt
!#-< $;%&WXX?)$]4](]V\]]#DWTWHWPVWWr<   c                8   < V ^8  d   QhRS[ RS[ R,          RR/# r   r5   )r7   r8   s   "r9   r:   r     s&     > > >sTz >t >r<   c                   V P                  WR 7      p\        V\        4      '       d4   V P                  P	                  VP
                  VP                  .R7       MrV P                  P                  VP                  VP                  V P                  VP                  VP                  VP                  R4      VP                  R4      R7       V P                  VP                  4       R7       R# )r_   deletecommit_messagecommit_description)rb   r]   r   r\   r_   r   r   r@   N)r   r   ri   r   batch_bucket_filesrk   r@   delete_filerb   r]   r   r\   r_   r[   r   rD   )rC   r@   r_   rx   r   s   &&&, r9   _rmHfFileSystem._rm  s    ))$)Bm%CDDII(()@)@-J\J\I](^II!!*77%--jj'11&//%zz*:;#)::.B#C "  	=#:#:#<=r<   c          
      R   < V ^8  d   QhRS[ RS[RS[R,          RS[ R,          RR/# )r3   r@   	recursivemaxdepthNr_   r4   r   )r7   r8   s   "r9   r:   r     sE     0> 0>0> 0> *	0>
 *0> 
0>r<   c                   V P                  WR7      pV P                  WW4R7      p\        V\        4      '       dk   V Uu. uF6  qP	                  V4      '       d   K  V P                  V4      P
                  NK8  	  ppV P                  P                  VP                  VR7       MV Uu. uF6  qP	                  V4      '       d   K  V P                  V4      P
                  NK8  	  p	pV	 U
u. uF  p
\        V
R7      NK  	  pp
RX R2pY'       d   RMR,          pYe   R
V R2MR,          pV P                  P                  VP                  VP                  V P                  VVP                  VP                  RV4      VP                  R4      R7       V P!                  VP#                  4       R7       R	# u upi u upi u up
i )ad  
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   r_   r   )rb   zDelete  zrecursively rX   Nzup to depth r   r   )r]   r\   r   
operationsr_   r   r   r   )r   expand_pathr   ri   isdirr@   r   r   rk   r   create_commitr]   r\   r   r_   r[   r   rD   )rC   r@   r   r   r_   rx   r   pathsr   paths_in_reporb   r   r   s   &&&&&,       r9   rmHfFileSystem.rm  s   6 ))$)B  X am%CDD?D]utJJW[L\2d''-22uF]II(()@)@(PFKdedS]S]^bSc9T..t499eMd_lm_l|/\J_lJm&tfA.N	nrAN<PXJa8VXXNII##%--'11jj%&//%zz*:NK#)::.B#C $  	=#:#:#<=% ^ ems    F8F8*F=F=,Gc                |   < V ^8  d   QhRS[ RS[RS[RS[ R,          RS[S[ S[S[ S[3,          ,          ,          /# )r3   r@   detailrefreshr_   Nr4   )r6   r   listdictr   )r7   r8   s   "r9   r:   r     sL     ); ););!%);7;);ORUYz);	cDcN"	#);r<   c                   V P                  WR7      pVP                  4       p V P                  ! V3RVRV/VB pV'       d   V# V Uu. uF  qR,          NK  	  up#   \         d    TP                  '       g   \        TR4        T P                  ! T P                  T4      3RTRT/TB pM  \         d    . p Mi ; iT Uu. uF  qR,          T8X  g   K  TNK  	  Mu upi pp\        T4      ^ 8X  d   \        TR4        Li ; iu upi )aG  
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
  r_   Nname)r   rD   _ls_treer   r@   r   r   r   )	rC   r@   r	  r
  r_   rx   r   outos	   &&&&&,   r9   lsHfFileSystem.ls  s   4 ))$)B&&(	2--SgSSFSC s:c":cV99c":: " 
	2 %%%%dD1mmDLL$6eeRZe^de% !7cvY$%611c7C73x1}%dD1
	2 #;sS   A 	D	D:D&B.-D.B>;D=B>>DC C $DDc                h   < V ^8  d   QhRS[ RS[RS[RS[ R,          RS[R,          RS[R,          /# )r3   r@   r   r
  r_   Nr   r   r   )r7   r8   s   "r9   r:   r     s[     K KK K 	K
 *K D[K *Kr<   c                x   Ve   TMV P                   e   V P                   MRpV P                  WR7      pVP                  4       pVP                  pV'       d   TM^p. p	WP                  9   Ed   V'       Eg   V P                  V,          p
V	P                  V
4       . pV'       d   ^p\        V
 Uu. uF  qR,          R8X  g   K  W3NK  	  up4      pV'       d   VP                  4       w  rVe	   W8:  g   K&  VR,          V P                  9  d   VP                  VR,          4       KX  V P                  VR,          ,          p
V	P                  V
4       TP                  V
 Uu. uF  pVR,          R8X  g   K  V^,           V3NK   	  up4       K  . pV'       dK   \        V\        4      '       d5   V	 Uu. uF(  pVR,          e   K  V P                  VR,          4      NK*  	  ppV'       d	   V'       g   V'       Ed}   V'       Edt   \        P                  P                  VV,           4      pVP                  R4      '       g   VV8X  g   V\!        VV4      9   d   VP#                  R4      MV P                  V4      pVe'   V\%        V4      R  P'                  R4      pVV,          pV	 Uu. uF,  pVR,          P)                  VR,           4      '       d   K*  VNK.  	  p	p\+        V P                  4       F?  pVP)                  VR,           4      '       g   K#  V P                  P-                  VR 4       KA  	  V P                  P-                  VR 4       V	P                  V P/                  VVRVVVR	7      4       V	# \        V\0        4      '       d*   V P3                  VP4                  VP                  VR
7      pMIV P6                  P9                  VP:                  VP                  VVVP<                  VP>                  R7      pV EF  pVR,           VP                  ,           p\        V\@        4      '       dP   RVRVPB                  RRRVPD                  RVPF                  RVPH                  RVPJ                  RVPL                  /pM\        V\N        4      '       d8   RVRVPB                  RRRVPH                  RVPP                  RVPR                  /pMK\        V\T        4      '       d"   RVR^ RRRVPV                  RVPJ                  /pMRVR^ RRRVPR                  /pV P                  VR,          4      pV P                  PY                  V. 4      P                  V4       V\%        V4      R  P'                  R4      pVe
   W8:  g   EK  V	P                  V4       EK  	  V	# u upi u upi u upi u upi )NFr   r   	directoryr  last_commitr>   T)r   r
  r_   r   r   )prefixr   )r   expandr_   r\   sizefileblob_idlfsxet_hashsecuritymtimeuploaded_attree_id)-r   r   rD   r?   r   extendr   popleftappendr   rR   r   osr@   commonprefixendswithr   rA   r   r   
startswithr  r}   r  ri   _list_bucket_tree_with_foldersrk   r   list_repo_treer]   r_   r\   r'   r  r  r  r  r  r  r#   r   r!  r(   r"  
setdefault)rC   r@   r   r
  r_   r   r   r   	root_pathr  cached_path_infosdirs_not_in_dircachedepth	path_infodirs_to_visitdir_infodirs_not_expandedr  common_prefixcommon_pathcommon_path_depthcached_pathtree
cache_pathcache_path_infoparent_paths   &&&&&&&                   r9   r  HfFileSystem._ls_tree  sC    '2KTM]M]Mi9I9Iot 	 ))$)B&&(!&&	(8a==  $d 3JJ()#%   %9Jo9JIX^N_cnNn'e'9Jo! $&3&;&;&=OE'5+<#F+4==@0778HI04hv>N0O-JJ'89)00 6G!"5F	'0'8K'G %;UQY	$:5F!" !#z-9[\\FI$fcQ}M]%<T\\!F)%<c!$f2HYHY !# 4 45IL]5] ^ %--c22$	1$.BDU(VV "((- m4  '(3CIK(@(F(Fs(K% 11H"%U#QQvY-A-A+PSBS-Tqq#U#'#6K"--kC.?@@))+t< $7 !!+t4

MM#"+ $!)$/!) " 	J 
s -)GHH::!++(--' ;  yy//!))!&&'&*33+55 0  "	&_y~~=
i22
	!9#4#4y}}"I$6$6%y'<'<"I$6$6	'O  	:66
	"I$6$6%y'<'<'O  	:66
!9#4#4%y'<'<'O 
%y'<'<	'O #ll?6+BC((b9@@Q"3t9;/55c:#u'8JJ/S "T 
a p!" %g" Vs0   2V(V(&V-;V-7V2	V2.'V7V7c          
      R   < V ^8  d   QhRS[ RS[ RS[RS[S[S[,          ,          /# )r3   rk   r  r   r4   )r6   r   r   r#   r$   )r7   r8   s   "r9   r:   r     s7     & &&&)&6:&	*|+	,&r<   c                   V P                   P                  WVR7      p/ pV'       d   ^VP                  R4      ,           M^ p. pV EF
  pVP                  V4       V'       g   K  \	        \        VP                  4      P                  4      RV) ^,
            F  p	\        R\        V	4      VP                  R7      p
V
P                  V9  d"   VP                  V
4       WV
P                  &   KV  V
P                  f   Kf  WZP                  ,          pVP                  e   VP                  V
P                  8  g   K  V
P                  Vn
        K  	  EK  	  V'       g   \        RV RV R24      hV# )	z<Same as `HfApi.list_bucket_tree` but always includes folders)r   r>   Nr  )r   r@   r!  zFile not found in bucket 'z': '')r   list_bucket_treer   r%  r  r   r@   parentsr$   r6   r!  r   )rC   rk   r  r   bucket_filesbucket_folders	min_depthr  bucket_entryparent_bucket_folder_strparent_bucket_folderbucket_folders   &&&&        r9   r*  +HfFileSystem._list_bucket_tree_with_folders  sS    yy11)y1Y24-3AS))	/1(LJJ|$  -1|?P?P1Q1Y1Y,Z[k^g]gjk]k,l('3$3/G+HVbVnVn($
 (,,NBJJ34@T#7#<#<= (33?$23L3L$MM$008%114H4T4TT4H4T4T1# -m )6 $'A)DQWPXXY%Z[[
r<   c          	      p   < V ^8  d   QhRS[ RS[S[S[ S[S[ ,          S[S[ ,          3,          ,          /# r3   r@   r4   )r6   r   r   r  )r7   r8   s   "r9   r:   r     s7     7 7 7(5d3iQUVYQZAZ;[2\ 7r<   c              /     <"   V P                  WP                  R4      R7      P                  4       p\        SV `  ! V.VO5/ VB  Rj  xL
  R#  L5i)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   N)r   r[   rD   rs   walk)rC   r@   rw   rx   ry   s   &&*,r9   rN  HfFileSystem.walk  sI        

:0F GQQS7<6t6v666s   AA
AAc                J   < V ^8  d   QhRS[ RS[R,          RS[S[ ,          /# )r3   r@   r   Nr4   )r6   r   r  )r7   r8   s   "r9   r:   r     s*     ? ? ?d
 ?S	 ?r<   c                   < V P                  WP                  R4      R7      P                  4       p\        SV `  ! V3RV/VB # )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.
r_   r   r   )r   r[   rD   rs   glob)rC   r@   r   rx   ry   s   &&&,r9   rR  HfFileSystem.glob  sC       

:0F GQQSw|D>8>v>>r<   c                   < V ^8  d   QhRS[ RS[R,          RS[RS[RS[RS[ R,          RS[S[ ,          S[S[ S[S[ S[3,          3,          ,          /# )	r3   r@   r   Nwithdirsr	  r
  r_   r4   )r6   r   r   r  r  r   )r7   r8   s   "r9   r:   r     st     ;7 ;7;7 *;7 	;7
 ;7 ;7 *;7 
cT#tCH~-.	.;7r<   c           	        Ve   V^8  d   \        R4      hV P                  WR7      pVP                  4       p V P                  ! V3RRRVRV/VB p	V'       g"   V	 U
u. uF  qR,          R8w  g   K  V
NK  	  p	p
M-V P                  ! V3/ VB pVR,          R8X  d   V.V	,           MT	p	V	 U
u/ uF  qR	,          V
bK  	  p	p
\        T	4      pT'       g   T# T Uu/ uF  qY,          bK  	  up# u up
i u up
i   \
         dB     T P                  ! T3R
T/TB R,          R8X  d   T/ /p	 Lj/ p	 Ln  \         d    / p	  L~i ; ii ; iu upi )aE  
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.
zmaxdepth must be at least 1r   r   Tr
  r   r   r  r  r_   r  )r   r   rD   r  infor   FileNotFoundErrorr   )rC   r@   r   rU  r	  r
  r_   rx   r   r  r  r1  namesr  s   &&&&&&&,      r9   findHfFileSystem.find  sh   @ HqL:;;))$)B&&(	.--ccgcPXc\bcC "%B#Q6k)Aqq#B !IId5f5	+4V+<+KykC'QT),-AV9a<C-sL056#)O66 C
 .! " 	99T?H??G6Q*CC$ 	* 7sG   C8 C.3C.-C3E8E%D/+D//E <E?E  Ec                >   < V ^8  d   QhRS[ RS[ RS[ R,          RR/# )r3   path1path2r_   Nr4   r5   )r7   r8   s   "r9   r:   r     s.     :? :?S :? :?d
 :?X\ :?r<   c                   V P                  WR7      pV P                  W#R7      p\        V\        4      '       g   \        V\        4      '       d   \        R4      hVP                  VP                  8H  ;'       d    VP
                  VP
                  8H  pV'       d   RV RV 2pV P                  P                  VP
                  VP                  VP                  VP                  RV4      VP                  RR4      \        VP                  VP                  VP                  R7      .R	7       MV P                  VR
VP                  R7      ;_uu_ 4       p	V	P                  4       p
RRR4       RV RV 2pV P                  P                  X
VP                  VP
                  V P                  VP                  VP                  VP                  RV4      VP                  R4      R7       V P!                  VP#                  4       R7       V P!                  VP#                  4       R7       R#   + '       g   i     L; i)aB  
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   rX   )src_path_in_reporb   src_revision)r]   r\   r_   r   r   r   rbNpath_or_fileobjrb   r]   r   r\   r_   r   r   r   )r   r   ri   r   r\   r]   r   r  r_   r[   r   rb   openreadupload_filer   r   rD   )rC   r]  r^  r_   rx   resolved_path1resolved_path2	same_repor   fcontents   &&&&,      r9   cp_fileHfFileSystem.cp_file  s     **5*D**5*Dn&DEE:J
 J
 &&QRR $$(@(@@uu^E[E[_m_u_uEu 	 $UG4w7NII##&..(22'00%zz*:NK#)::.BB#G')7)D)D%3%@%@%3%<%< $  5$1H1HIIQ&&( J$UG4w7NII!! '+88&..jj(22'00%zz*:NK#)::.B#C " 	 	>#;#;#=>>#;#;#=> JIs   H..H>	c                &   < V ^8  d   QhRS[ RS[/# rL  )r6   r
   )r7   r8   s   "r9   r:   r   S  s     h hS hx hr<   c                <   V P                   ! V3/ / VCRR/CB pRV9   d.   VR,          f   \        RV R24      hVR,          P                  # RV9   d   VR,          '       d
   VR,          # RV9   d   VR,          '       d
   VR,          # \        RV R	V R
24      h)a+  
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  z9'modified' is not implemented for repository paths like 'r@  r   r!  z'Cannot determined 'modified' for path 'z	' (info: ))rW  r   date)rC   r@   rx   rW  s   &&, r9   modifiedHfFileSystem.modifiedS  s     yyA!@F!@M4!@AD M"*),efjekkl*mnn&+++_g= d"tM':':&&%(OPTvU^_c^dde&fggr<   c          
      V   < V ^8  d   QhRS[ RS[RS[ R,          RS[S[ S[3,          /# )r3   r@   r
  r_   Nr4   )r6   r   r  r   )r7   r8   s   "r9   r:   r   l  s@     l l lt lsTz l_cdgildl_m lr<   c                   V P                  WR7      pVP                  4       pTP                  RV P                  e   V P                  MR4      pVP                  '       g   RVR^ RR/p\        V\        4      '       d   RVR	&   \        V\        4      '       d   V'       dx   V P                  P                  VP                  VP                  VP                  R
7      R,          p/ VCRRR	\        VP                  VP                  VP                  R7      /CpEM\        V\         4      '       dt   V P#                  V4      p	V P%                  WR7       V P&                  V	,           U
u. uF  qR,          V8X  g   K  V
NK  	  pp
V'       g   \)        VR4       V^ ,          pEMCRpV P#                  V4      p	V'       g"   WP&                  9  d   V P%                  V	4       WP&                  9   dO   V P&                  V	,           U
u. uF  qR,          V8X  g   K  V
NK  	  pp
V'       g   \)        VR4       V^ ,          pV'       g#   Ve   V'       Ed   V'       Ed   VR	,          Ef   V P                  P+                  VP                  VP,                  VVP                  VP                  R7      pV'       g   \)        VR4       V^ ,          p\        VP                  VP                  VP                  RVP.                  R7      P                  4       p\        V\0        4      '       dh   RVR,           VP                  ,           RVP2                  RRRVP4                  RVP6                  RVP8                  R	VP:                  RVP<                  /pM8RVR,           VP                  ,           R^ RRRVP>                  R	VP:                  /pV'       g   R Uu/ uF  qW,          bK  	  ppVf   Q hV# u up
i u up
i u upi )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).

> [!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  r  )r\   r_   r"  )oidtitlerr  )r
  )r  r_   r\   rX   )rb   r^   r>   r  r  r  r  r  )r  r  r   ) r   rD   r[   r   r@   r   rR   r   list_repo_commitsr]   r\   r_   r&   	commit_idrx  
created_atri   r   r  r   r   get_paths_inforb   r^   r'   r  r  r  r  r  r  r"  )rC   r@   r
  r_   rx   r   r   r  r  r<  r  out1
paths_infor1  r-  ks   &&&&,           r9   rW  HfFileSystem.infol  s   , ))$)B&&(jjt/?/?/K4++QV
 !!! C
 -)KLL%)M"-)KLLQ\"ii99!))]5L5LWdWmWm : t!>'119J9JQ\QgQg$ 'EFF,,t,KGGKG1#}}[9O9!vY$=NAA9DO%dD1q'CC,,t,K;mm#C$mm+#'==#=S#=a6dAR#=S)$51g#+++###mBTB\!YY55!))!..&*33+55 6 
 ")$5&qM	>!++!))!**!#"/"="= )+  i22	C).. @	!9#4#4y}}"I$6$6%y'<'<"I$6$6	C 	C).. @!9#4#4%y'<'<C #.FG.Fcf9.FCG
q P TT Hs   )O/=O/O4O4O9c                     VP                  RR4      '       d   V P                  V4       V P                  ! V3/ VB  R#   \         d     R# i ; i)aq  
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)r[   r   rW  OSError)rC   r@   rx   s   &&,r9   existsHfFileSystem.exists  sL     	zz)U++%%d+IId%f% 		s   A  $A   AAc                ^     V P                  V4      R,          R8H  #   \         d     R# i ; i)a)  
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.
r   r  FrW  r  rC   r@   s   &&r9   r  HfFileSystem.isdir  s1    	99T?6*k99 		    ,,c                ^     V P                  V4      R,          R8H  #   \         d     R# i ; i)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.
r   r  Fr  r  s   &&r9   isfileHfFileSystem.isfile  s1    	99T?6*f44 		r  c                &   < V ^8  d   QhRS[ RS[ /# rL  r5   )r7   r8   s   "r9   r:   r     s        r<   c                   V P                  V4      p\        V\        4      '       d3   V P                   RVP                   R\        VP                  4       2pMB\        VP                  VP                  VP                  VP                  V P                  R7      pV P                  V4      '       d   VP                  RR^4      pV# )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/)r\   r_   r   z/tree/)r   r   ri   r   rk   r   r@   r    r]   rb   r\   r_   r  replace)rC   r@   r   urls   &&  r9   r  HfFileSystem.url  s     ))$/m%CDD]]O9]-D-D,EYuUbUgUgOhNijC%%**'11&//C ::d++k8Q7C
r<   c                   < V ^8  d   QhRR/# r3   r4   NrG   )r7   r8   s   "r9   r:   r   1  s     <  < \` < r<   c                @  < VP                  R4      p\        VP                  4       4      R0,
          p\        V\        \
        34      '       d   \        V4      ^ 8  d   \        SV `   ! W3RVRV/VB # \        V4      '       d   TpM1V P                  V4      '       d   \        P                  ! VRR7       R# \        V\        \        34      '       d6   \        P                  ! \        P                  P!                  V4      RR7       RpVf   \#        VR4      pRpVP%                  4       p	V P'                  WR	7      p
V P)                  WR	7      R
,          pVP+                  V4        \-        V P/                  V
P1                  4       4      TTT^ V P2                  P5                  4       \        V\
        4      '       d   VP6                  MRR7       VP9                  V	4       V'       d   VP;                  4        R# R#   T'       d   TP;                  4        i i ; i)a  
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.

r_   callbackoutfileT)exist_okNFwbr   r  )r  	temp_filedisplayed_filenameexpected_sizeresume_sizeheaders	_tqdm_bar)r[   setkeysr   r   r   r   rs   get_filer   r  r&  makedirsr6   r   r@   dirnamere  tellr   rW  set_sizer!   r  rD   r   _build_hf_headerstqdmseekclose)rC   rpathlpathr  r  rx   r_   unhandled_kwargs
close_fileinitial_posresolve_remote_pathr  ry   s   &&&&&,      r9   r  HfFileSystem.get_file1  s   $ ::j)v{{}-<(\<$@AASIYEZ]^E^ 7#E_8_W_X^__ eGZZKK-ec4[))KK.> 
?5$'GJlln #///I		%	;FC-(	 HH0::<=!#(+		335+5h+M+M(--SW LL%  z s   ,A:H Hc                    \        R4      h)zA 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   rB   s   &r9   transactionHfFileSystem.transactiono  s     ""LMMr<   c                    \        R4      h)z@Begin write transaction for deferring files, non-context versionr  r  rB   s   &r9   start_transactionHfFileSystem.start_transactionz  s     ""LMMr<   c                p    \         \        V 4      V P                  V P                  V P	                  4       33# rr   )make_instancer   r   r   r   rB   s   &r9   
__reduce__HfFileSystem.__reduce__  s9    J  $$&	
 
 	
r<   c                    R \        V P                  4      R\        V P                  4      R\        V P                  4      /# )r   r   r   )r   r   r   r   rB   s   &r9   r    HfFileSystem._get_instance_state  s:    /-x8\8\/]"HT-F-F$G
 	
r<   )r   r   r   r   r   r   r   r   rr   )rb  NN)FNN)TFN)FFNNN)NFFFN)FN)(rH   rI   rJ   rK   rL   root_markerprotocolrt   classmethodr~   r   r   r   r   r   r   r  r  r  r*  rN  rR  rZ  rm  rs  rW  r  r  r  r  r   r  propertyr  r  r  r   rN   rO   r   r   s   @@r9   r   r      sl    @D KH<  $< $(	<
 "&< $(< <2 	 	T T&4 4M
 M
^Q QBX X$> > 0> 0>d); );VK KZ& &P7 7 ? ?$;7 ;7z:? :?xh h2l l\2$$ 4 /@ <  < | N NN

 
r<   r   )	metaclassc                      a a ] tR tRt oRV3R lV 3R llltV 3R ltV3R lR ltV3R lR ltRV3R	 lR
 lltRV 3R llt	V3R lR lt
RtVtV ;t# )r   i  c                :   < V ^8  d   QhRS[ RS[RS[R,          /# )r3   fsr@   r_   N)r   r6   )r7   r8   s   "r9   r:   HfFileSystemFile.__annotate__  s&     
 
< 
s 
cDj 
r<   c                  <  VP                  W#R 7      V n        \        ST `  ! YP                  P                  4       3/ TB  T  R#   \         d-   pRTP                  RR4      9   d   \        T R24      Thh Rp?ii ; i)r   wr   rX   B.
Make sure the repository and revision exist before writing data.N)r   r   rX  r[   rs   rt   rD   )rC   r  r@   r_   rx   r   ry   s   &&&&, r9   rt   HfFileSystemFile.__init__  s    	!#!ID 	//99;FvF ! 	fjj,,'c\] 	s   A A>'A99A>c                H   < \        V R 4      '       g   R# \        SV `	  4       # r   N)hasattrrs   __del__rC   ry   s   &r9   r  HfFileSystemFile.__del__  s     t_--w  r<   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r3   startendr4   )r   bytes)r7   r8   s   "r9   r:   r    s"      # C E r<   c                    R RV RV^,
           2/V P                   P                  P                  4       CpV P                  4       p\	        RWC\
        P                  R7      p\        V4       VP                  # )rangebytes=-GETr  r   )	r  r   r  r  r+   r   HF_HUB_DOWNLOAD_TIMEOUTr*   rl  )rC   r  r  r  r  rs   &&&   r9   _fetch_rangeHfFileSystemFile._fetch_range  sk    veWAcAgY/
ggll,,.
 hhji>_>_`Ayyr<   c                   < V ^8  d   QhRR/# r  rG   )r7   r8   s   "r9   r:   r    s     S S$ Sr<   c                @    \         P                  ! R RR7      V n        R# )zhffs-F)r  r   N)tempfileNamedTemporaryFiler  rB   s   &r9   _initiate_upload!HfFileSystemFile._initiate_upload  s    !44GERr<   c                $   < V ^8  d   QhRS[ RR/# )r3   finalr4   N)r   )r7   r8   s   "r9   r:   r    s      4 D r<   c                h   V P                   P                  ^ 4       V P                   P                  4       pV P                  P	                  V4       V'       Ed   V P                  P                  4        \        V P                  \        4      '       dh   V P                  P                  P                  V P                  P                  V P                  P                  V P                  P                  3.R7       MV P                  P                  P                  V P                  P                  V P                  P                   V P                  P"                  V P                  P$                  V P                  P&                  V P                  P(                  V P*                  P-                  R4      V P*                  P-                  R4      R7       \.        P0                  ! V P                  P                  4       V P                  P3                  V P                  P5                  4       R7       R# R# )r   )addr   r   rc  r   N)bufferr  rf  r  writer  r   r   ri   r  r   r   rk   r  r@   rg  rb   r]   r   r\   r_   rx   r[   r&  remover   rD   )rC   r  blocks   && r9   _upload_chunkHfFileSystemFile._upload_chunk  s     "U#5NN  "$,,.LMM//&&008K8KTM_M_MdMd7e6f 0  (($(NN$7$7!%!3!3!@!@ ..66''--"00::!//88#';;??3C#D'+{{7K'L ) 	 IIdnn))*GG$$''113 % % r<   c                  < V P                   R8X  d   Ve   VR8X  d   V P                  ^ 8X  dp   V P                  P                  V P                  R^ R7      ;_uu_ 4       pVP                  4       pV ;P                  \        V4      ,          un        VuuRRR4       # \        SV `  V4      #   + '       g   i     L; i)zRead 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.
rb  N)r   ry  )r   locr  re  r@   rf  r   rs   )rC   lengthrk  r  ry   s   &&  r9   rf  HfFileSystemFile.read  s     99&.FbLdhhRSmdii!<<ffhCH$ =< w|F##	 =<s   4B--B=	c                    < V ^8  d   QhRS[ /# r2   r5   )r7   r8   s   "r9   r:   r         & &S &r<   c                L    V P                   P                  V P                  4      # rr   r  r  r@   rB   s   &r9   r  HfFileSystemFile.url      ww{{499%%r<   )r   r  rr   )Fry  )rH   rI   rJ   rK   rt   r  r  r  r  rf  r  rN   rO   r   r   s   @@r9   r   r     sH     
 
! S S 4$& & &r<   r   c                      a a ] tR tRt oRV3R lV 3R llltRV3R lR lltRV3R lR lltRV3R lR	 lltV3R
 lR ltV 3R lt	R t
R tRtVtV ;t# )r   i  c                L   < V ^8  d   QhRS[ RS[RS[RS[R,          RS[RS[/# )r3   r  r@   r   r_   Nr   
cache_typer   r6   r   )r7   r8   s   "r9   r:   #HfFileSystemStreamFile.__annotate__  sK     !* !*!* !* 	!*
 *!* !* !*r<   c           	     4  < V^ 8w  d   \        RV 24      hVR8w  d   \        RV 24      hRV9   d   \        RV R24      h VP                  W$R7      V n        RV P                  P                  4       RR/V n        \        S	V `   ! WP                  P                  4       3RVRVRV/VB  RV n	        V  \        4       V n        RV n        \        4       V n        R#   \         d1   pRTP	                  RR	4      9   d   \        T R
24      Th Rp?LRp?ii ; i)r   z:HfFileSystemStreamFile only supports block_size=0 but got nonez?HfFileSystemStreamFile only supports cache_type='none' but got r  z;HfFileSystemStreamFile only supports reading but got mode='r@  r   r   rX   r  Nr  r  r   r  )r   r   r   rX  r[   rD   detailsrs   rt   responser   _exit_stack_stream_iterator	bytearray_stream_buffer)
rC   r  r@   r   r_   r   r  rx   r   ry   s
   &&&&&&&, r9   rt   HfFileSystemStreamFile.__init__  sB    ?YZdYefgg^_i^jkll$;Z[_Z``abcc	!#!ID  2 2 < < >M"",,.	
59	
FP	
]g	
kq	
 04$;8<'k ! 	fjj,,'c\] -	s   C D'&DDc                &   < V ^8  d   QhRS[ RS[ /# )r3   r  whencer   )r7   r8   s   "r9   r:   r      s     : : :S :r<   c                j    V^ 8X  d
   V^8X  d   R# WP                   8X  d
   V^ 8X  d   R# \        R4      h)r   NzCannot seek streaming HF file)r  r   )rC   r  r  s   &&&r9   r  HfFileSystemStreamFile.seek   s0    !8!((?v{899r<   c                    < V ^8  d   QhRS[ /# )r3   r  r  )r7   r8   s   "r9   r:   r     s     $ $3 $r<   c                   V P                   f   V P                  4        Rp  V P                   e   V P                  f   R# V P                  V P                  V4      pV ;P                  \        V4      ,          un        V#   \         dH    T P                   e   T P                   P                  4        T'       d   h T P                  4        Rp K  i ; i)zRead 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.
FTr<   )r  _open_connectionr  _read_from_streamr  r   r   r  )rC   r  retried_oncer  s   &&  r9   rf  HfFileSystemStreamFile.read  s     == !!#$==(D,A,A,I,,T-B-BFKCH$
 $==,MM'')%%'#$s   B ?B :C<CCc                <   < V ^8  d   QhRS[ S[,          RS[RS[/# )r3   iteratorr  r4   )r   r  r   )r7   r8   s   "r9   r:   r   #  s'        (5/  3  PU  r<   c                   V^ 8X  d   R# V^ 8  dU   \        V P                  4      pV P                  P                  4        V F  pVP                  V4       K  	  \	        V4      # V\        V P                  4      8:  d*   \	        V P                  RV 4      pV P                  RV1 V# \        V P                  4      pV P                  P                  4        V Fi  pV\        V4      ,
          pV\        V4      8  d   VP                  V4       K8  VP                  VRV 4       V P                  P                  WFR 4        M	  \	        V4      # )zRead 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<   N)r  r  r   r#  r  r   )rC   r  r  bufchunkresultneeds   &&&    r9   r  (HfFileSystemStreamFile._read_from_stream#  s#    Q;A:D//0C%%'!

5! ":S,,--4..w78F##GVG,M++,!!#ECH$Dc%j 

5!

5$<(##**5<8  Szr<   c                    < V ^8  d   QhRS[ /# r2   r5   )r7   r8   s   "r9   r:   r   E  r  r<   c                L    V P                   P                  V P                  4      # rr   r  rB   s   &r9   r  HfFileSystemStreamFile.urlE  r  r<   c                |   < \        V R 4      '       g   R# V P                  P                  4        \        SV `  4       # r  )r  r  r  rs   r  r  s   &r9   r  HfFileSystemStreamFile.__del__H  s2    t_-- w  r<   c                    \         V P                  V P                  V P                  V P                  V P
                  P                  33# rr   )reopenr  r@   r   	blocksizecacher  rB   s   &r9   r  !HfFileSystemStreamFile.__reduce__O  s0    DIIt~~tzzWWWr<   c           	     P   V P                   P                  4        RV n        V P                  4       pV P                  P
                  P                  4       pV P                  ^ 8  d   RV P                   R2VR&   V P                  P                  \        RVV\        P                  R7      4      V n         \        V P                  4       T P                  P#                  4       T n        R#   \         d/   pTP                  P                   R8X  d   RT n         Rp?R# h Rp?ii ; i)z%Open a connection to the remote file.Nr  r  Ranger  r  i  )r  r   r  r  r  r   r  r  r  enter_contextr,   r   r  r  r*   r   status_code
iter_bytes)rC   r  r  r   s   &   r9   r  'HfFileSystemStreamFile._open_connectionR  s     	!!# $hhj'',,00288a<!'z3GG((66!99	
	. !% 8 8 :  	zz%%, $	s   6C, ,D%7"D D  D%)r  r  r  r  r   r  )rb  Nr   r  )r   r  )rH   rI   rJ   rK   rt   r  rf  r  r  r  r  r  rN   rO   r   r   s   @@r9   r   r     sN     !* !*F: :$ $8   D& &!X; ;r<   r   c                0    V ^8  d   QhR\         R\         /# )r3   r_   r4   r5   )r7   s   "r9   r:   r:   q  s     ] ]C ]C ]r<   c                 T    \         P                  ! V 4      '       d   V # \        V 4      # rr   )r"   match
safe_quoter   s   &r9   ra   ra   q  s#    288BB8\
S[H\\r<   c                0    V ^8  d   QhR\         R\         /# )r3   sr4   r5   )r7   s   "r9   r:   r:   u  s      # # r<   c                     \        V R R7      # )rX   )safe)r   )r2  s   &r9   r0  r0  u  s    r<   c                J    V ^8  d   QhR\         R\        R,          R\        /# )r3   r@   r   Nr4   )r6   r   r   )r7   s   "r9   r:   r:   y  s&     * * *)d*: *x *r<   c                     T p\        V\        4      '       d   V  R 2pM7\        V\        4      '       d   V  R2pM\        V\        4      '       d   V  R2p\	        V4      Vh)z (repository not found)z (revision not found)z (invalid repository id))r   r   r   r)   rX  )r@   r   msgs   && r9   r   r   y  se    
C#.//-.	C.	/	/+,	C*	+	+./
C
 c)r<   c          
      T    V ^8  d   QhR\         R\        R\        R\        R\        /# )r3   r  r@   r   r   r  r  )r7   s   "r9   r:   r:     s7     R R| R3 Rc Rs RPS Rr<   c                 (    V P                  WW4R 7      # ))r   r   r  )re  )r  r@   r   r   r  s   &&&&&r9   r#  r#    s    774z7QQr<   c                 `    V ! V/ VB pVP                  4        F  w  rV\        WEV4       K  	  V# rr   )r   r   )rv   rw   rx   r   r  r   r   s   &&&&   r9   r  r    s6    	d	f	B+113+& 4Ir<   c                @    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r3   _cached_base)__conditional_annotations__r   )r7   s   "r9   r:   r:      s    		f 4 3c 3g 
r<   )Xr=  r&  r  r   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   rX   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.   r0   rR   ri   r   AbstractFileSystemr<  rp   r   specAbstractBufferedFiler   r   ra   r0  r   r#  r  hffsr:   )r=  s   @r9   <module>rV     sK   		    .    (   ' ' ' '   J J & #  C  0 v v v j j ' 6 6 6 &)A & &0 0%= 0 0 223 32l 2jB
6,, B
J H&v{{77 H&VR;V[[== R;j]*R ~r<   