+
    –°³jx²  ã                   ó€  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHt ^ RIHtHt ^ RIHt ^ RIHtHtHt ^RIHtHt ^RIHt ^R	IHt ^R
IHtHtHtH t H!t!H"t"H#t# ^RI$H%t% ]'       d   ^RI&H't' ]PP                  ! ])4      t*Rt+Rt,] ! R R4      4       t-] ! R R4      4       t.] ! R R4      4       t/] ! R R4      4       t0]! RR7       ! R R4      4       t1] ! R R4      4       t2] ! R R4      4       t3] ! R R 4      4       t4R! R" lt5R# R$ lt6] ! R% R&4      4       t7] ! R' R(4      4       t8 ! R) R*4      t9R+ R, lt:R- R. lt;R/ R0 lt<R1 R2 lt=R3 R4 lt>R5R/R6 R7 llt?RUR9 R: llt@R; R< ltAR= R> ltBR? R@ ltCRVRA RB lltDRC RD ltERWRER8RFR8RGR8RHR8RIR8RJRRKRRLRRMRRNRROR8RPR8RQR8RRR/RS RT llltFR# )XzzShared logic for bucket operations.

This module contains the core buckets logic used by both the CLI and the Python API.
N)ÚIterator)Ú	dataclassÚfield)ÚdatetimeÚtimezone)ÚPath)ÚTYPE_CHECKINGÚAnyÚLiteral)Ú	constantsÚlogging)Ú_validate_relative_filename)ÚBucketNotFoundError)ÚHfUriÚ
StatusLineÚXetFileDataÚdisable_progress_barsÚenable_progress_barsÚparse_datetimeÚparse_hf_uri)Ú_looks_like_hf_url©ÚHfApizhf://buckets/éè  c                   ó6   a € ] tR t^?t o RtR tV 3R ltRtV tR# )Ú
BucketInfoa«  
Contains information about a bucket on the Hub. This object is returned by [`bucket_info`] and [`list_buckets`].

Attributes:
    id (`str`):
        ID of the bucket.
    private (`bool`):
        Is the bucket private.
    created_at (`datetime`):
        Date of creation of the bucket on the Hub.
    size (`int`):
        Size of the bucket in bytes.
    total_files (`int`):
        Total number of files in the bucket.
c                ó,  € VP                  R 4      V n        VP                  R4      V n        \        VP                  R4      4      V n        VP                  R4      V n        VP                  R4      V n        V P                  P                  ! R/ VB  R# )ÚidÚprivateÚ	createdAtÚsizeÚ
totalFilesN© )	Úpopr   r   r   Ú
created_atr    Útotal_filesÚ__dict__Úupdate)ÚselfÚkwargss   &,ÚY/home/luca/screen-checking/.venv/lib/python3.14/site-packages/huggingface_hub/_buckets.pyÚ__init__ÚBucketInfo.__init__W   sm   € Ø—*‘*˜TÓ"ˆŒØ—z‘z )Ó,ˆŒÜ(¨¯©°KÓ)@ÓAˆŒØ—J‘J˜vÓ&ˆŒ	Ø!Ÿ:™: lÓ3ˆÔØ�‰×ÒÑ&˜vÔ&ó    c                óV   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[;R&   # )é   r   r   r$   r    r%   )ÚstrÚboolr   Úint)ÚformatÚ__classdict__s   "€r*   Ú__annotate__ÚBucketInfo.__annotate__?   sC   ø‡ ‚ ñ$ 	�Gñ% ñ& �Mñ' ñ( Ññ) ñ* �Iñ+ ñ, Ñò- r-   )r$   r   r   r    r%   N©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r+   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r4   s   @r*   r   r   ?   s   ø‡ € ñò,'÷1 ƒ r-   r   c                   ó†   a € ] tR t^`t o ]! RR7      t]! RR7      t]! RR7      t]! RR7      tV 3R lR lt	V 3R lt
RtV tR# )	Ú_BucketAddFileN©ÚdefaultF©Úinitc                ó   <€ V ^8„  d   QhRR/# ©r/   ÚreturnNr"   )r3   r4   s   "€r*   r5   Ú_BucketAddFile.__annotate__j   s   ø€ ÷ 	
ñ 	
˜tñ 	
r-   c                ó   € R V n         \        V P                  \        \        34      '       d-   \
        P                  ! V P                  4      ^ ,          V n         V P                   f-   \
        P                  ! V P                  4      ^ ,          V n         \        \        V P                  \        4      '       g1   \        P                  P                  V P                  4      R,          M\        P                  ! 4       R,          4      V n        R # )Nr   )Úcontent_typeÚ
isinstanceÚsourcer0   r   Ú	mimetypesÚ
guess_typeÚdestinationr2   ÚbytesÚosÚpathÚgetmtimeÚtimeÚmtime©r(   s   &r*   Ú__post_init__Ú_BucketAddFile.__post_init__j   s¯   € Ø ˆÔÜ�d—k‘k¤C¬ ;×/Ò/Ü )× 4Ò 4°T·[±[Ó AÀ!Õ DˆDÔØ×ÑÒ$Ü )× 4Ò 4°T×5EÑ5EÓ FÀqÕ IˆDÔäÜ8BÀ4Ç;Á;ÔPU×8VÒ8VŒB�G‰G×Ñ˜TŸ[™[Ó)¨DÖ0Ô\`×\eÒ\eÓ\gÐjnÕ\nó
ˆŽ
r-   c                ó¬   <€ V ^8„  d   Qh/ S[ S[,          S[,          ;R&   S[ ;R&   S[ R,          ;R&   S[R,          ;R&   S[;R&   S[ R,          ;R&   # )r/   rN   rQ   NÚxet_hashr    rW   rL   )r0   r   rR   r2   )r3   r4   s   "€r*   r5   rJ   `   sf   ø‡ ‚ á‘$�J™ÕÑñ ñ Ññ ñ
 �D�jÑ.ñ ñ ��*Ñ*ñ ñ Ñ"ñ ñ ˜•*Ñ0ò r-   ©rL   rW   )r8   r9   r:   r;   r   r\   r    rW   rL   rY   r=   r>   r?   r@   s   @r*   rB   rB   `   s@   ø‡ € ñ
 !¨Ô.€HÙ TÔ*€DÙ˜EÔ"€EÙ$¨%Ô0€L÷	
ð 	
÷ ƒ r-   rB   c                   ót   a € ] tR t^vt o ]! RR7      t]! RR7      t]! RR7      tV 3R lR ltV 3R lt	Rt
V tR# )	Ú_BucketCopyFileNrC   FrE   c                ó   <€ V ^8„  d   QhRR/# rH   r"   )r3   r4   s   "€r*   r5   Ú_BucketCopyFile.__annotate__€   s   ø€ ÷ -ñ -˜tñ -r-   c                ó²   € \         P                  ! V P                  4      ^ ,          V n        \	        \
        P
                  ! 4       R,          4      V n        R# )é    r   N)rO   rP   rQ   rL   r2   rV   rW   rX   s   &r*   rY   Ú_BucketCopyFile.__post_init__€   s7   € Ü%×0Ò0°×1AÑ1AÓBÀ1ÕEˆÔÜœŸš› tÕ+Ó,ˆŽ
r-   c                óŠ   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[R,          ;R&   S[;R&   S[ R,          ;R&   # )	r/   rQ   r\   Úsource_repo_typeÚsource_repo_idNr    rW   rL   )r0   r2   )r3   r4   s   "€r*   r5   ra   v   se   ø‡ ‚ áÑñ ñ �Mñ ñ Ññ	 ñ
 Ññ ñ ��*Ñ*ñ ñ Ñ"ñ ñ ˜•*Ñ0ò r-   r]   )r8   r9   r:   r;   r   r    rW   rL   rY   r=   r>   r?   r@   s   @r*   r_   r_   v   s6   ø‡ € ñ  TÔ*€DÙ˜EÔ"€EÙ$¨%Ô0€L÷-ð -÷ ƒ r-   r_   c                   ó,   a € ] tR t^…t o V 3R ltRtV tR# )Ú_BucketDeleteFilec                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r/   rT   )r0   )r3   r4   s   "€r*   r5   Ú_BucketDeleteFile.__annotate__…   s   ø‡ ‚ á
�Iò r-   r"   N)r8   r9   r:   r;   r=   r>   r?   r@   s   @r*   ri   ri   …   s   ø‡ ‡ „ r-   ri   T)Úfrozenc                   ó0   a € ] tR t^Št o RtV 3R ltRtV tR# )ÚBucketFileMetadataa	  Data structure containing information about a file in a bucket.

Returned by [`get_bucket_file_metadata`].

Args:
    size (`int`):
        Size of the file in bytes.
    xet_file_data (`XetFileData`):
        Xet information for the file (hash and refresh route).
c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   # )r/   r    Úxet_file_data)r2   r   )r3   r4   s   "€r*   r5   ÚBucketFileMetadata.__annotate__Š   s   ø‡ ‚ ñ �Iñ ñ Ñò r-   r"   N)r8   r9   r:   r;   r<   r=   r>   r?   r@   s   @r*   rn   rn   Š   s   ø‡ € ñ	÷ ƒ r-   rn   c                   ó|   a € ] tR t^›t o RtRt]! RR7      t]! RR7      t]! RR7      t	V 3R lR lt
V 3R ltRtV tR	# )
Ú	BucketUrla�  Describes a bucket URL on the Hub.

`BucketUrl` is returned by [`create_bucket`]. At initialization, the URL is parsed to populate properties:
- endpoint (`str`)
- namespace (`str`)
- bucket_id (`str`)
- url (`str`)
- uri (`HfUri`)

Args:
    url (`str`):
        String value of the bucket url.
    endpoint (`str`, *optional*):
        Endpoint of the Hub. Defaults to <https://huggingface.co>.
Ú FrE   c                ó   <€ V ^8„  d   QhRR/# rH   r"   )r3   r4   s   "€r*   r5   ÚBucketUrl.__annotate__³   s   ø€ ÷ ñ ˜tñ r-   c                óò  € V P                   ;'       g    \        P                  V n         V P                  P	                  V P                   R 4      P                  R4      pVP                  R4      '       d   V\        R4      R p\        V4      pVP                  '       d   \        RV P                   24      hVP                  P                  R4      ^ ,          V n        VP                  V n        W n        R# )rt   Ú/zbuckets/NzUnable to parse bucket URL: )Úendpointr   ÚENDPOINTÚurlÚreplaceÚstripÚ
startswithÚlenÚ_parse_bucket_uriÚpath_in_repoÚ
ValueErrorr   ÚsplitÚ	namespaceÚ	bucket_idÚuri)r(   Úurl_pathÚparseds   &  r*   rY   ÚBucketUrl.__post_init__³   sº   € ØŸ™×;Ð;¬×);Ñ);ˆŒð —8‘8×#Ñ# D§M¡M°2Ó6×<Ñ<¸SÓAˆà×Ñ˜z×*Ò*Ø¤ J£Ð 1Ð2ˆHÜ" 8Ó,ˆØ××ÐÜÐ;¸D¿H¹H¸:ÐFÓGÐGØŸ™Ÿ™¨Ó-¨aÕ0ˆŒØŸ™ˆŒØŽr-   c                óV   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   # )r/   r{   ry   r„   r…   r†   ©r0   r   )r3   r4   s   "€r*   r5   rv   ›   sE   ø‡ ‚ ñ$ 
�Hñ% ñ& Ññ' ñ( Ñ&ñ) ñ* Ñ&ñ+ ñ, 
Ñ"ò- r-   )r…   ry   r„   r†   N)r8   r9   r:   r;   r<   ry   r   r„   r…   r†   rY   r=   r>   r?   r@   s   @r*   rs   rs   ›   s@   ø‡ € ñð" €HÙ Ô&€IÙ Ô&€IÙ˜EÔ"€C÷ð ÷1 ƒ r-   rs   c                   ó6   a € ] tR t^Ãt o RtR tV 3R ltRtV tR# )Ú
BucketFilezŸ
Contains information about a file in a bucket on the Hub. This object is returned by [`list_bucket_tree`].

Similar to [`RepoFile`] but for files in buckets.
c                ót  € VP                  R 4      V n        VP                  R4      V n        VP                  R4      V n        VP                  R4      V n        VP                  RR4      pV'       d   \        V4      MRV n        VP                  RR4      pV'       d   \        V4      V n        R# RV n        R# )ÚtyperT   r    ÚxetHashrW   NÚ
uploadedAt)r#   r�   rT   r    r\   r   rW   Úuploaded_at)r(   r)   rW   r’   s   &,  r*   r+   ÚBucketFile.__init__Ò   sˆ   € Ø—J‘J˜vÓ&ˆŒ	Ø—J‘J˜vÓ&ˆŒ	Ø—J‘J˜vÓ&ˆŒ	ØŸ
™
 9Ó-ˆŒØ—
‘
˜7 DÓ)ˆß.3”^ EÔ*¸ˆŒ
Ø—j‘j ¨tÓ4ˆß:Eœ>¨+Ó6ˆÖÈ4ˆÖr-   c                óŒ   <€ V ^8„  d   Qh/ S[ R,          ;R&   S[;R&   S[;R&   S[;R&   S[R,          ;R&   S[R,          ;R&   # )	r/   Úfiler�   rT   r    r\   NrW   r’   )r
   r0   r2   r   )r3   r4   s   "€r*   r5   ÚBucketFile.__annotate__Ã   s\   ø‡ ‚ ñ �&�/Ññ ñ �Iñ ñ �Iñ ñ �Mñ ñ �d�?Ññ ñ ˜D•Ñ ò r-   )rW   rT   r    r�   r’   r\   Nr7   r@   s   @r*   r�   r�   Ã   s   ø‡ € ñòP÷ ƒ r-   r�   c                   ó6   a € ] tR t^Ýt o RtR tV 3R ltRtV tR# )ÚBucketFolderz¬
Contains information about a directory in a bucket on the Hub. This object is returned by [`list_bucket_tree`].

Similar to [`RepoFolder`] but for directories in buckets.
c                ó8  € VP                  R 4      V n        VP                  R4      V n        VP                  RR4      ;'       g    VP                  RR4      pV'       d3   \        V\        4      '       d
   VV n        R# \        V4       V n        R# RV n        R# )r�   rT   r‘   Nr’   )r#   r�   rT   rM   r   r   r’   )r(   r)   r’   s   &, r*   r+   ÚBucketFolder.__init__é   s‚   € Ø—J‘J˜vÓ&ˆŒ	Ø—J‘J˜vÓ&ˆŒ	Ø—j‘j ¨tÓ4×WÐW¸¿
¹
À=ÐRVÓ8Wˆ÷ ô ' {´H×=Ò=ˆ[ð 	ÖÜCQÐR]ÔC^ð 	Öð ð 	Ör-   c                óZ   <€ V ^8„  d   Qh/ S[ R,          ;R&   S[;R&   S[R,          ;R&   # )r/   Ú	directoryr�   rT   Nr’   )r
   r0   r   )r3   r4   s   "€r*   r5   ÚBucketFolder.__annotate__Ý   s4   ø‡ ‚ ñ �+Õ
Ññ ñ �Iñ ñ ˜D•Ñ ò r-   )rT   r�   r’   Nr7   r@   s   @r*   r˜   r˜   Ý   s   ø‡ € ñò
÷ ƒ r-   r˜   c                ó0   € V ^8„  d   QhR\         R\        /# ©r/   rT   rI   r‹   )r3   s   "r*   r5   r5   ù   s   € ÷ Cñ CœCð C¤Eñ Cr-   c                óÜ  € V P                  \        P                  4      '       g   \        V 4      '       d/   \	        V 4      pVP
                  '       g   \        RV  R24      hV# V P                  R^4      p\        V4      ^8  g   V^ ,          '       d   V^,          '       g   \        RV  R24      hV^ ,           RV^,           2pRP                  VR,          4      p\        RW4R7      # )	zíParse a bucket path into a HfUri.

Accepts:
- `hf://buckets/namespace/name(/path/in/repo)` URIs,
- Hugging Face web URLs such as `https://huggingface.co/buckets/namespace/name(/tree/path)`,
- plain `namespace/name(/path/in/repo)` paths.
zInvalid bucket path: z*. Must be a bucket URI (hf://buckets/...).rx   zInvalid bucket path: 'z)'. Expected format: namespace/bucket_name:r/   NNÚbucket)r�   r   r�   )r~   r   ÚHF_PROTOCOLr   r   Ú	is_bucketr‚   rƒ   r   Újoinr   )rT   rˆ   Úpartsr…   Úprefixs   &    r*   r€   r€   ù   sÍ   € ð ‡�”y×,Ñ,×-Ò-Ô1CÀD×1IÒ1Iä˜dÓ#ˆØ××ÐÜÐ4°T°FÐ:dÐeÓfÐfØˆØ�J‰J�s˜AÓ€EÜ
ˆ5ƒz�A„~˜U 1ŸXœX¨U°1¯X¬XÜÐ1°$°Ð7`ÐaÓbÐbØ˜•8�*˜A˜e A�h˜ZÐ(€IØ�X‰X�e˜B•iÓ €FÜ�h 9ÔBÐBr-   c                ó0   € V ^8„  d   QhR\         R\        /# rŸ   ©r0   r1   )r3   s   "r*   r5   r5     s   € ÷ (ñ (œ#ð (¤$ñ (r-   c                óz   € V P                  \        P                  4      '       g   R# \        V 4      P                  # )z�Check if a path is a bucket path.

Do not raise if the path is not a hf:// URI.
Raise if the path is a hf:// URI but with an incorrect format.
F)r~   r   r¢   r   r£   )rT   s   &r*   Ú_is_bucket_pathrª     s-   € ð �?‰?œ9×0Ñ0×1Ò1ÙÜ˜Ó×'Ñ'Ð'r-   c                   óD   a € ] tR tRt o RtRtRtRtRtRt	V 3R lt
RtV tR# )ÚSyncOperationi  z,Represents a sync operation to be performed.Nrt   c                ó´   <€ V ^8„  d   Qh/ S[ R	,          ;R&   S[;R&   S[R,          ;R&   S[;R&   S[R,          ;R&   S[R,          ;R&   S[R,          ;R&   # )
r/   ÚactionrT   Nr    ÚreasonÚlocal_mtimeÚremote_mtimeÚbucket_file)ÚuploadÚdownloadÚdeleteÚskip)r
   r0   r2   r�   )r3   r4   s   "€r*   r5   ÚSyncOperation.__annotate__  sv   ø‡ ‚ ñ Ð:Õ;Ñ;ñ	 ñ
 �Iñ ñ ��*Ññ ñ Ññ ñ �t•Ñ"ñ ñ ˜•*Ñ#ñ ñ ˜dÕ"Ñ)ò r-   r"   )r8   r9   r:   r;   r<   r    r¯   r°   r±   r²   r=   r>   r?   r@   s   @r*   r¬   r¬     s*   ø‡ € á6ð €DØ€FØ"€KØ#€LØ%)€K÷ ƒ r-   r¬   c                   óT   a € ] tR tRt o Rt]! ]R7      tV 3R lR ltV 3R lt	Rt
V tR# )	ÚSyncPlani,  z Represents a complete sync plan.)Údefault_factoryc                óF   <€ V ^8„  d   QhRS[ S[S[S[,          3,          /# )r/   rI   )Údictr0   r2   )r3   r4   s   "€r*   r5   ÚSyncPlan.__annotate__5  s!   ø€ ÷ 
ñ 
™™c¡3©¥9˜nÕ-ñ 
r-   c           
     ó2  € \        R  V P                   4       4      p\        R V P                   4       4      p\        R V P                   4       4      p\        R V P                   4       4      p\        R V P                   4       4      pRVRVRVRVR	V/# )
c              3   óJ   "  € T F  qP                   R 8X  g   K  ^x € K  	  R# 5i)r³   N©r®   ©Ú.0Úops   & r*   Ú	<genexpr>Ú#SyncPlan.summary.<locals>.<genexpr>6  ó   é € ÐK¡/˜B·Y±YÀ(Ñ5J—a’a£/ùó   ‚#™
#c              3   óJ   "  € T F  qP                   R 8X  g   K  ^x € K  	  R# 5i)r´   NrÀ   rÁ   s   & r*   rÄ   rÅ   7  s   é € ÐO¡O˜b·y±yÀJÑ7NŸš£OùrÇ   c              3   óJ   "  € T F  qP                   R 8X  g   K  ^x € K  	  R# 5i)rµ   NrÀ   rÁ   s   & r*   rÄ   rÅ   8  rÆ   rÇ   c              3   óJ   "  € T F  qP                   R 8X  g   K  ^x € K  	  R# 5i)r¶   NrÀ   rÁ   s   & r*   rÄ   rÅ   9  s   é € ÐG¡˜"·9±9ÀÑ3F—A’A£ùrÇ   c              3   ór   "  € T F-  qP                   R9   g   K  VP                  ;'       g    ^ x € K/  	  R# 5i)r³   N©r³   r´   )r®   r    rÁ   s   & r*   rÄ   rÅ   :  s(   é € Ðg±¨"Ç9Á9ÐPfÑCfœ˜Ÿ™Ÿ˜ Aœ³ùs   ‚7™7¬7ÚuploadsÚ	downloadsÚdeletesÚskipsÚ
total_size)ÚsumÚ
operations)r(   rÍ   rÎ   rÏ   rÐ   rÑ   s   &     r*   ÚsummaryÚSyncPlan.summary5  s‰   € ÜÑK $§/¢/ÓKÓKˆÜÑO D§O¢OÓOÓOˆ	ÜÑK $§/¢/ÓKÓKˆÜÑG §¢ÓGÓGˆÜÑg°·²ÓgÓgˆ
à�wØ˜Ø�wØ�UØ˜*ð
ð 	
r-   c                óZ   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[S[,          ;R&   # )r/   rN   ÚdestÚ	timestamprÓ   )r0   Úlistr¬   )r3   r4   s   "€r*   r5   r½   ,  s;   ø‡ ‚ ñ �Kñ	 ñ
 �Iñ ñ �Nñ ñ ‘]Õ#ÑAò r-   r"   N)r8   r9   r:   r;   r<   r   rÙ   rÓ   rÔ   r=   r>   r?   r@   s   @r*   r¹   r¹   ,  s%   ø‡ € á*ñ
 ',¸DÔ&A€J÷
ð 
÷ ƒ r-   r¹   c                   óL   a € ] tR tRt o RtR	V 3R lR lltV 3R lR ltRtV tR# )
ÚFilterMatcheriI  z4Matches file paths against include/exclude patterns.Nc          	      óœ   <€ V ^8„  d   QhRS[ S[,          R,          RS[ S[,          R,          RS[ S[S[S[3,          ,          R,          /# )r/   Úinclude_patternsNÚexclude_patternsÚfilter_rules)rÙ   r0   Útuple)r3   r4   s   "€r*   r5   ÚFilterMatcher.__annotate__L  sM   ø€ ÷ /ñ /á™s�) dÕ*ð/ñ ™s�) dÕ*ð/ñ ™5¡¡c �?Õ+¨dÕ2ñ	/r-   c                ól   € T;'       g    . V n         T;'       g    . V n        T;'       g    . V n        R# )zêInitialize the filter matcher.

Args:
    include_patterns: Patterns to include (from --include)
    exclude_patterns: Patterns to exclude (from --exclude)
    filter_rules: Rules from filter file as list of ("+"/"-", pattern) tuples
N©rÝ   rÞ   rß   )r(   rÝ   rÞ   rß   s   &&&&r*   r+   ÚFilterMatcher.__init__L  s4   € ð !1× 6Ð 6°BˆÔØ 0× 6Ð 6°BˆÔØ(×.Ð.¨BˆÖr-   c                ó&   <€ V ^8„  d   QhRS[ RS[/# rŸ   r¨   )r3   r4   s   "€r*   r5   rá   ]  s   ø€ ÷ ñ ™Cð ¡Dñ r-   c                óf  € V P                    F(  w  r#\        P                  ! W4      '       g   K#  VR8H  u # 	  V P                   F"  p\        P                  ! W4      '       g   K!   R# 	  V P                   F"  p\        P                  ! W4      '       g   K!   R# 	  V P                  '       d   R# R# )zÞCheck if a path should be included based on the filter rules.

Filtering rules:
- Filters are evaluated in order, first matching rule decides
- If no rules match, include by default (unless include patterns are specified)
Ú+FT)rß   ÚfnmatchrÞ   rÝ   )r(   rT   ÚsignÚpatterns   &&  r*   ÚmatchesÚFilterMatcher.matches]  s�   € ð "×.Ô.‰MˆDÜ�Š˜t×-Ô-Ø˜s‘{Ò"ñ /ð
 ×,Ô,ˆGÜ�Š˜t×-Ô-Úñ -ð ×,Ô,ˆGÜ�Š˜t×-Ô-Úñ -ð
 × × Ð Ùñ r-   )rÞ   rß   rÝ   )NNN)	r8   r9   r:   r;   r<   r+   rë   r>   r?   r@   s   @r*   rÛ   rÛ   I  s   ø‡ € Ù>÷/ò /÷"ö r-   rÛ   c                óh   € V ^8„  d   QhR\         R\        \        \         \         3,          ,          /# )r/   Úfilter_filerI   )r0   rÙ   rà   )r3   s   "r*   r5   r5   z  s'   € ÷ ñ ¤Cð ¬D´´s¼C°xµÕ,Añ r-   c                ó  € . p\        V 4      ;_uu_ 4       pV FÉ  pVP                  4       pV'       d   VP                  R4      '       d   K4  VP                  R4      '       d+   VP                  RVR,          P                  4       34       Ku  VP                  R4      '       d+   VP                  RVR,          P                  4       34       K¶  VP                  RV34       KË  	  RRR4       V#   + '       g   i     T# ; i)zêParse a filter file and return a list of (sign, pattern) tuples.

Filter file format:
- Lines starting with "+" are include patterns
- Lines starting with "-" are exclude patterns
- Empty lines and lines starting with "#" are ignored
Ú#rç   ºé   NNÚ-N)Úopenr}   r~   Úappend)rî   ÚrulesÚfÚlines   &   r*   Ú_parse_filter_filerù   z  sÃ   € ð €EÜ	ˆk×	Ô	˜aÛˆDØ—:‘:“<ˆDß˜4Ÿ?™?¨3×/Ò/ÙØ�‰˜s×#Ò#Ø—‘˜c 4¨¥8§>¡>Ó#3Ð4Ö5Ø—‘ ×%Ò%Ø—‘˜c 4¨¥8§>¡>Ó#3Ð4Ö5ð —‘˜c 4˜[Ö)ñ ÷ 
ð €L÷ 
Ö	ð €Lús   –4C0ÁC0Á$A C0Â%AC0Ã0D	c                ó`   € V ^8„  d   QhR\         R\        \        \        3,          R,          /# )r/   rT   rI   N)r0   rà   r2   Úfloat)r3   s   "r*   r5   r5   —  s(   € ÷ *ñ *”cð *œe¤C¬ JÕ/°$Õ6ñ *r-   c                óâ   €  \         P                  ! V 4      p\        P                  ! TP                  4      '       d   R# TP
                  TP                  R,          3#   \         d     R# i ; i)z»Stat a local file and return (size, mtime_ms).

Returns None if the path is missing or is a directory. Uses a single
``os.stat`` call so callers don't pay for multiple syscalls per file.
Nr   )rS   ÚstatÚOSErrorÚS_ISDIRÚst_modeÚst_sizeÚst_mtime)rT   Ústs   & r*   Ú_stat_localr  —  sX   € ðÜ�WŠW�T‹]ˆô ‡|‚|�B—J‘J×ÒÙØ�:‰:�r—{‘{ TÕ)Ð)Ð)øô	 ô Úðús   ‚A ÁA.Á-A.c                ór   € V ^8„  d   QhR\         R\        \        \         \        \        3,          ,          /# )r/   Ú
local_pathrI   )r0   r   rà   r2   rû   )r3   s   "r*   r5   r5   ¦  s*   € ÷ 7ñ 7¤#ð 7¬(´5¼¼cÄ5¸Õ3IÕ*Jñ 7r-   c              #  ó
  "  € \         P                  P                  V 4      p \         P                  P                  V 4      '       g   \	        RV  24      h\         P
                  ! V 4       F’  w  rpV F†  p\         P                  P                  W4      p\        V4      pVf   K3  \         P                  P                  WP4      pVP                  \         P                  R4      pWv^ ,          V^,          3x € Kˆ  	  K”  	  R# 5i)zgList all files in a local directory.

Yields:
    tuple: (relative_path, size, mtime_ms) for each file
z Local path must be a directory: Nrx   )rS   rT   ÚabspathÚisdirr‚   Úwalkr¤   r  Úrelpathr|   Úsep)r  ÚrootÚ_ÚfilesÚfilenameÚ	full_pathÚ	stat_infoÚrel_paths   &       r*   Ú_list_local_filesr  ¦  sÀ   é € ô —‘—‘ Ó,€JÜ�7‰7�=‰=˜×$Ò$ÜÐ;¸J¸<ÐHÓIÐIäŸ'š' *Ö-‰ˆ�ÛˆHÜŸ™Ÿ™ TÓ4ˆIÜ# IÓ.ˆIØÒ ÙÜ—w‘w—‘ yÓ=ˆHà×'Ñ'¬¯©°Ó4ˆHØ a�L¨)°A­,Ð6Ô6ó ó .ùs   ‚DDc                óŒ   € V ^8„  d   QhRRR\         R\         R\        \        \         \        \        \
        3,          ,          /# )r/   Úapir   r…   r¦   rI   )r0   r   rà   r2   rû   r	   )r3   s   "r*   r5   r5   ¼  s?   € ÷ 2ñ 2˜Gð 2´ð 2¼Sð 2ÄXÌeÔTWÔY\Ô^cÔehÐThÕNiÕEjñ 2r-   c              #  ó  "  € T P                  Y;'       g    RRR7       Fà  p\        V\        4      '       d   K  VP                  pV'       d`   VP	                  VR,           4      '       d   V\        V4      ^,           R pM-WB8X  d$   RV9   d   VP                  R^4      R,          MTpMKŽ  Tp\        V4       VP                  '       d"   VP                  P                  4       R,          M^ pWSP                  Wc3x € Kâ  	  R# 5i)zÄList all files in a bucket with a given prefix.

Yields:
    tuple: (relative_path, size, mtime_ms, bucket_file) for each file.
        bucket_file is the BucketFile object from list_bucket_tree.
NT)r¦   Ú	recursiverx   r   éÿÿÿÿ)Úlist_bucket_treerM   r˜   rT   r~   r   Úrsplitr   rW   rØ   r    )r  r…   r¦   ÚitemrT   r  Úmtime_mss   &&&    r*   Ú_list_remote_filesr  ¼  sÓ   é € ð ×$Ñ$ Y·~°~ÀÐQUÐ$ÖVˆÜ�dœL×)Ò)ÙØ�y‰yˆ÷ Ø�‰˜v¨�|×,Ò,Ø¤ F£¨a¥Ð 1Ð2‘Ø”à69¸T´k˜4Ÿ;™; s¨AÓ.¨rÖ2Àt‘ñ àˆHä# HÔ-Ø48·J·J°J�4—:‘:×'Ñ'Ó)¨DÖ0ÀAˆØŸ	™	 8Ð1Ô1ó+ Wùs   ‚ADÁDÁ-BDc                ó0   € V ^8„  d   QhR\         R\        /# )r/   r  rI   )rû   r0   )r3   s   "r*   r5   r5   à  s   € ÷ Pñ PœEð P¤cñ Pr-   c                óx   € \         P                  ! V R,          \        P                  R7      P	                  4       # )z3Convert mtime in milliseconds to ISO format string.r   )Útz)r   Úfromtimestampr   ÚutcÚ	isoformat)r  s   &r*   Ú_mtime_to_isor%  à  s&   € ä×!Ò! (¨T¥/´h·l±lÔC×MÑMÓOÐOr-   r²   c                óÐ   € V ^8„  d   QhR\         R\        R,          R\        R\        R\        R\        R\         R\         R	\        R
\        R\        R\
        R,          R\        /# )r/   rT   r®   Úsource_sizeÚsource_mtimeÚ	dest_sizeÚ
dest_mtimeÚsource_newer_labelÚdest_newer_labelÚignore_sizesÚignore_timesÚignore_existingr²   NrI   rÌ   )r0   r
   r2   rû   r1   r	   r¬   )r3   s   "r*   r5   r5   å  s´   € ÷ ESñ ESä
ðESô Ð(Õ)ðESô ð	ESô
 ðESô ðESô ðESô ðESô ðESô ðESô ðESô ðESô �t•ðESô ñESr-   c           	     ó(  € \        VR8X  d   TMT4      p\        VR8X  d   TMT4      pRV RVRVRV/pV
'       d   \        RRRRR	/VB # W$8g  pW5,
          \        8„  pV'       dD   V'       d   \        RRVRVR
V/VB # WS,
          \        8„  pV'       d   TMRp\        RRRRV/VB # V	'       d)   V'       d   \        RRVRRR
V/VB # \        RRRRR/VB # V'       g	   V'       d   V'       d   RMTp\        RRVRVR
V/VB # \        RRRRR/VB # )aS  Compare source and dest files and return the appropriate sync operation.

This is a unified helper for both upload and download directions.

Args:
    path: Relative file path
    action: "upload" or "download"
    source_size: Size of the source file (bytes)
    source_mtime: Mtime of the source file (milliseconds)
    dest_size: Size of the destination file (bytes)
    dest_mtime: Mtime of the destination file (milliseconds)
    source_newer_label: Label when source is newer (e.g., "local newer" or "remote newer")
    dest_newer_label: Label when dest is newer (e.g., "remote newer" or "local newer")
    ignore_sizes: Only compare mtime
    ignore_times: Only compare size
    ignore_existing: Skip files that exist on receiver
    bucket_file: BucketFile object (for downloads only)

Returns:
    SyncOperation describing the action to take
r³   rT   r    r°   r±   r®   r¶   r¯   z&exists on receiver (--ignore-existing)r²   z
same mtimezsize differsz	same sizeÚ	identicalr"   )r%  r¬   Ú_SYNC_TIME_WINDOW_MS)rT   r®   r'  r(  r)  r*  r+  r,  r-  r.  r/  r²   Úlocal_mtime_isoÚremote_mtime_isoÚbase_kwargsÚsize_differsÚsource_newerÚ
dest_newerÚskip_reasonr¯   s   $$$$$$$$$$$$        r*   Ú_compare_files_for_syncr:  å  sW  € ôH $°F¸hÔ4F¡LÈJÓW€OÜ$°6¸XÔ3E¡ZÈ<ÓXÐð 	�Ø�Ø�ØÐ(ð	#€K÷ ÜÑk FÐkÐ3[ÐkÐ_jÑkÐkàÑ+€LØ Õ-Ô1EÑE€LçßÜ Ñr¨ÐrÐ7IÐrÐWbÐrÐfqÑrÐrà$Õ3Ô7KÑKˆJß.8Ñ*¸lˆKÜ ÑR¨ÐR°{ÐRÀkÑRÐRß	ßÜ Ñn¨Ðn°~ÐnÐS^ÐnÐbmÑnÐnä ÑR¨ÐR°{ÐRÀkÑRÐRçŸ<ß'3‘^Ð9KˆFÜ Ñf¨Ðf°vÐfÈ;ÐfÐZeÑfÐfä ÑR¨ÐR°{ÐRÀkÑRÐRr-   Fc                ó°   € V ^8„  d   QhR\         R\         RRR\        R\        R\        R\        R	\        R
\        R,          R\        R,          R\        /# )r/   rN   r×   r  r   rµ   r.  r-  Úexistingr/  Úfilter_matcherNÚstatusrI   )r0   r1   rÛ   r	   r¹   )r3   s   "r*   r5   r5   -  sŒ   € ÷ tñ tÜðtä
ðtð 
ðtô ð	tô
 ðtô ðtô ðtô ðtô " DÕ(ðtô �$�Jðtô ñtr-   c
                ól  € T;'       g    \        4       p\        V 4      '       * ;'       d    \        V4      p
\        V 4      ;'       d    \        V4      '       * pV
'       g   V'       g   \        R4      h\        V V\        P
                  ! \        P                  4      P                  4       R7      pRpV
'       Ed‘   \        P                  P                  V 4      p\        V4      pVP                  VP                  pp\        P                  P                  V4      '       g   \        RV 24      h/ p\!        V4       FM  w  pppVP#                  V4      '       d   VV3VV&   V	'       g   K/  V	P%                  R\'        V4       R24       KO  	  V	'       d   V	P)                  R\'        V4       R24       / pV	'       d    VP+                  V4      P,                  p \1        VVV4       F[  w  ppppVP#                  V4      '       d   VV3VV&   V	'       g   K0  Ve   RV 2MRpV	P%                  R	\'        V4       V R24       K]  	  V	'       d   V	P)                  R	\'        V4       R24       \9        VP;                  4       4      \9        VP;                  4       4      ,          pV	'       d   V	P)                  R\'        V4       R24       \=        V4       EFo  pVP?                  V4      pVP?                  V4      pV'       d•   V'       g�   V'       dC   VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      R7      4       K€  VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      R7      4       KÂ  V'       dE   V'       d=   Vw  ppVw  pp VP@                  PC                  \I        VRVVVV RRVVVR7      4       EK  V'       d   EK  V'       g   EK$  V'       g   EK/  VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      R7      4       EKr  	  V# \        V 4      pVP                  VP                  pp\        P                  P                  V4      p/ p/ p!V	'       d    VP+                  V4      P,                  p\1        VVV4       F`  w  pppp"VP#                  V4      '       d   VV3VV&   V"V!V&   V	'       g   K5  Ve   RV 2MRpV	P%                  R	\'        V4       V R24       Kb  	  V	'       d   V	P)                  R	\'        V4       R24       / p\        P                  P                  V4      '       dÍ   V'       d^   \!        V4       FM  w  pppVP#                  V4      '       d   VV3VV&   V	'       g   K/  V	P%                  R\'        V4       R24       KO  	  MgV Fa  p\        P                  PK                  VV4      p#\M        V#4      p$V$f   K4  V$VV&   V	'       g   KC  V	P%                  R\'        V4       R24       Kc  	  V	'       d   V	P)                  R\'        V4       R24       \9        VP;                  4       4      \9        VP;                  4       4      ,          pV	'       d   V	P)                  R\'        V4       R24       \=        V4       EF�  pVP?                  V4      pVP?                  V4      pV'       d¥   V'       g�   V'       dC   VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      R7      4       K€  VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      V!P?                  V4      R7      4       KÒ  V'       dU   V'       dM   Vw  pp Vw  ppVP@                  PC                  \I        VRVV VVRRVVVV!P?                  V4      R7      4       EK.  V'       d   EK9  V'       g   EKD  V'       g   EKO  VP@                  PC                  \E        RVV^ ,          R\G        V^,          4      R7      4       EK’  	  V#   \.         d     EL—i ; i  \2         d    \4        P7                  R
T R24        ELUi ; i  \.         d     ELùi ; i)zvCompute the sync plan by comparing source and destination.

Returns:
    SyncPlan with all operations to be performed
z[One of source or dest must be a bucket path (hf://buckets/...) and the other must be local.©rN   r×   rØ   NzSource must be a directory: zScanning local directory (z files)rx   rt   zScanning remote bucket (zBucket 'z' not found, treating as empty.zComparing files (z paths)r¶   znew file (--existing))r®   rT   r    r¯   r°   r³   znew filezlocal newerzremote newer)rT   r®   r'  r(  r)  r*  r+  r,  r-  r.  r/  rµ   znot in source (--delete))r®   rT   r    r¯   r±   r´   )r®   rT   r    r¯   r±   r²   )rT   r®   r'  r(  r)  r*  r+  r,  r-  r.  r/  r²   )'rÛ   rª   r‚   r¹   r   Únowr   r#  r$  rS   rT   r  r€   r   r�   r	  r  rë   r'   r   ÚdoneÚbucket_infor%   Ú	Exceptionr  r   ÚloggerÚdebugÚsetÚkeysÚsortedÚgetrÓ   rõ   r¬   r%  r:  r¤   r  )%rN   r×   r  rµ   r.  r-  r<  r/  r=  r>  Ú	is_uploadÚis_downloadÚplanÚremote_totalr  rˆ   r…   r¦   Úlocal_filesr  r    r  Úremote_filesr  Ú	total_strÚ	all_pathsrT   Ú
local_infoÚremote_infoÚ
local_sizer°   Úremote_sizer±   Úbucket_file_mapr²   Ú
local_filer  s%   &&&&&&&&&&                           r*   Ú_compute_sync_planrY  -  sž  € ð" $×6Ð6¤}£€NÜ# FÓ+Ô+×EÐE´ÀÓ0E€IÜ! &Ó)×GÐG´/À$Ó2GÔ.G€KçŸ[ÜÐvÓwÐwäØØÜ—,’,œxŸ|™|Ó,×6Ñ6Ó8ô€Dð  $€Lß€yä—W‘W—_‘_ VÓ,ˆ
Ü" 4Ó(ˆØ"ŸI™I v×':Ñ':�6ˆ	ä�w‰w�}‰}˜Z×(Ò(ÜÐ;¸J¸<ÐHÓIÐIð ˆÜ(9¸*Ö(EÑ$ˆH�d˜HØ×%Ñ% h×/Ò/Ø)-¨xÐ(8�˜HÑ%ß‰vØ—‘Ð :¼3¸{Ó;KÐ:LÈGÐTÖUñ	 )F÷
 Ø�K‰KÐ4´S¸Ó5EÐ4FÀgÐNÔOàˆßðØ"Ÿ™¨yÓ9×EÑE�ð		PÜ/AÀ#ÀyÐRXÖ/YÑ+�˜$ ¨!Ø!×)Ñ)¨(×3Ò3Ø.2°HÐ-=�L Ñ*ß‘6Ø6BÒ6N ! L >Ñ 2ÐTV�IØ—M‘MÐ$<¼SÀÓ=NÐ<OÐPYÈ{ÐZaÐ"bÖcñ 0Z÷ Ø�K‰KÐ2´3°|Ó3DÐ2EÀWÐMÔNô ˜×(Ñ(Ó*Ó+¬c°,×2CÑ2CÓ2EÓ.FÕFˆ	ßØ�K‰KÐ+¬C°	«NÐ+;¸7ÐCÔDÜ˜9×%ˆDØ$Ÿ™¨Ó.ˆJØ&×*Ñ*¨4Ó0ˆKç§+çà—O‘O×*Ñ*Ü%Ø#)Ø!%Ø!+¨A¥Ø#:Ü(5°jÀµmÓ(Dôöð —O‘O×*Ñ*Ü%Ø#+Ø!%Ø!+¨A¥Ø#-Ü(5°jÀµmÓ(Dôö÷ §à*4Ñ'�
˜KØ,7Ñ)�˜\Ø—‘×&Ñ&Ü+Ø!Ø'Ø$.Ø%0Ø"-Ø#/Ø+8Ø)7Ø%1Ø%1Ø(7ô÷÷  ’Z§K¢K·F²Fà—‘×&Ñ&Ü!Ø'Ø!Ø(¨�^Ø9Ü%2°;¸qµ>Ó%Bô÷ña &ðV €Kô_ # 6Ó*ˆØ"ŸI™I v×':Ñ':�6ˆ	Ü—W‘W—_‘_ TÓ*ˆ
ð ˆØ*,ˆßðØ"Ÿ™¨yÓ9×EÑE�ô 6HÈÈYÐX^Ö5_Ñ1ˆH�d˜H kØ×%Ñ% h×/Ò/Ø*.°Ð)9�˜XÑ&Ø,7� Ñ)ß‰vØ2>Ò2J˜a ˜~Ñ.ÐPR�	Ø—‘Ð 8¼¸\Ó9JÐ8KÈIÈ;ÐV]Ð^Ö_ñ 6`÷ Ø�K‰KÐ2´3°|Ó3DÐ2EÀWÐMÔNàˆÜ�7‰7�=‰=˜×$Ò$ßä0AÀ*Ö0MÑ,�H˜d HØ%×-Ñ-¨h×7Ò7Ø15°xÐ0@˜ HÑ-ß‘vØŸ™Ð(BÄ3À{ÓCSÐBTÐT[Ð&\Ö]ò	 1Nó !-�HÜ!#§¡§¡¨j¸(Ó!C�JÜ +¨JÓ 7�IØ Ò(Ù Ø,5�K Ñ)ß‘vØŸ™Ð(BÄ3À{ÓCSÐBTÐT[Ð&\Ö]ñ !-÷ Ø�K‰KÐ4´S¸Ó5EÐ4FÀgÐNÔOô ˜×)Ñ)Ó+Ó,¬s°;×3CÑ3CÓ3EÓ/FÕFˆ	ßØ�K‰KÐ+¬C°	«NÐ+;¸7ÐCÔDÜ˜9×%ˆDØ&×*Ñ*¨4Ó0ˆKØ$Ÿ™¨Ó.ˆJç§:çà—O‘O×*Ñ*Ü%Ø#)Ø!%Ø!,¨Q¥Ø#:Ü)6°{À1µ~Ó)Fôöð —O‘O×*Ñ*Ü%Ø#-Ø!%Ø!,¨Q¥Ø#-Ü)6°{À1µ~Ó)FØ(7×(;Ñ(;¸DÓ(Aôö	÷ §à,7Ñ)�˜\Ø*4Ñ'�
˜KØ—‘×&Ñ&Ü+Ø!Ø)Ø$/Ø%1Ø",Ø#.Ø+9Ø)6Ø%1Ø%1Ø(7Ø$3×$7Ñ$7¸Ó$=ô÷÷  !’[§Z¢Z·F²Fà—‘×&Ñ&Ü!Ø'Ø!Ø'¨�]Ø9Ü$1°*¸Qµ-Ó$@ô÷ñe &ðx €Køô} ô Úðûô #ô 	Pä�L‰L˜8 I ;Ð.MÐN×Oð	Pûô` ô Úðús<   Ça' Ç8a9 È/a9 Òb$ á'a6á5a6á9$b!â b!â$b3â2b3c                ó(   € V ^8„  d   QhR\         RR/# ©r/   rM  rI   N©r¹   )r3   s   "r*   r5   r5   )  s   € ÷ ,ñ ,”hð , dñ ,r-   c                óJ  € RRRV P                   RV P                  RV P                  RV P                  4       /pVP	                  \
        P                  ! V4      R,           4       V P                   F®  pRRR	VP                  R
VP                  RVP                  /pVP                  e   VP                  VR&   VP                  e   VP                  VR&   VP                  e   VP                  VR&   VP	                  \
        P                  ! V4      R,           4       K°  	  R# )z1Write a sync plan as JSONL to a file-like object.r�   ÚheaderrN   r×   rØ   rÔ   Ú
Ú	operationr®   rT   r¯   Nr    r°   r±   )rN   r×   rØ   rÔ   ÚwriteÚjsonÚdumpsrÓ   r®   rT   r¯   r    r°   r±   )rM  r÷   r^  rÃ   Úop_dicts   &&   r*   Ú_write_planre  )  sì   € ð 	�Ø�$—+‘+Ø�—	‘	Ø�T—^‘^Ø�4—<‘<“>ð€Fð ‡G�GŒD�JŠJ�vÓ Õ%Ô&ð �oŒoˆà�KØ�b—i‘iØ�B—G‘GØ�b—i‘ið	#
ˆð �7‰7ÒØ Ÿg™gˆG�F‰OØ�>‰>Ò%Ø%'§^¡^ˆG�MÑ"Ø�?‰?Ò&Ø&(§o¡oˆG�NÑ#Ø	�‰”—
’
˜7Ó# dÕ*Ö+ó r-   c                ó4   € V ^8„  d   QhR\         R\        RR/# )r/   rM  Ú	plan_filerI   N)r¹   r0   )r3   s   "r*   r5   r5   F  s!   € ÷ ñ ”Xð ¬#ð °$ñ r-   c                ó~   € \        VR4      ;_uu_ 4       p\        W4       RRR4       R#   + '       g   i     R# ; i)z!Save a sync plan to a JSONL file.ÚwN)rô   re  )rM  rg  r÷   s   && r*   Ú
_save_planrj  F  s(   € ä	ˆi˜×	Ô	 Ü�DÔ÷ 
×	×	Ò	ús   •+«<	c                ó0   € V ^8„  d   QhR\         R\        /# )r/   rg  rI   )r0   r¹   )r3   s   "r*   r5   r5   L  s   € ÷ #ñ #œ#ð #¤(ñ #r-   c                óÚ  € \        V 4      ;_uu_ 4       pVP                  4       pRRR4       X'       g   \        RV  24      h\        P                  ! V^ ,          4      pVP                  R4      R8w  d   \        R4      h\        VR,          VR,          VR,          R	7      pVR
,           F¦  p\        P                  ! V4      pVP                  R4      R8w  d   K1  VP                  P                  \        VR,          VR,          VP                  R4      VP                  RR4      VP                  R4      VP                  R4      R7      4       K¨  	  V#   + '       g   i     EL=; i)z#Load a sync plan from a JSONL file.NzEmpty plan file: r�   r^  z0Invalid plan file: expected header as first linerN   r×   rØ   r@  rñ   r`  r®   rT   r    r¯   rt   r°   r±   )r®   rT   r    r¯   r°   r±   )
rô   Ú	readlinesr‚   rb  ÚloadsrJ  r¹   rÓ   rõ   r¬   )rg  r÷   Úlinesr^  rM  rø   rd  s   &      r*   Ú
_load_planrp  L  s(  € ä	ˆi�Œ˜AØ—‘“ˆ÷ 
÷ ÜÐ,¨Y¨KÐ8Ó9Ð9ô �ZŠZ˜˜a�Ó!€FØ‡z�z�&Ó˜XÔ%ÜÐKÓLÐLäØ�hÕØ�F�^Ø˜Õ%ô€Dð �b—	�	ˆÜ—*’*˜TÓ"ˆØ�;‰;�vÓ +Ô-ÙØ�‰×ÑÜØ˜xÕ(Ø˜V•_Ø—[‘[ Ó(Ø—{‘{ 8¨RÓ0Ø#ŸK™K¨Ó6Ø$Ÿ[™[¨Ó8ôö		
ñ	 ð €K÷C 
�ˆús   ”EÅE*	c          
      óR   € V ^8„  d   QhR\         RRR\        R\        R,          RR/# )r/   rM  r  r   Úverboser>  NrI   )r¹   r1   r	   )r3   s   "r*   r5   r5   w  s<   € ÷ eñ eœð e wð e¼ð eÌsÐUYÍzð eÐeiñ er-   c                ó<  € \        V P                  4      '       * ;'       d    \        V P                  4      p\        V P                  4      ;'       d    \        V P                  4      '       * pV P                   F  p\	        VP
                  4       K  	  V'       Ed{   \        P
                  P                  V P                  4      p\        V P                  4      pVP                  VP                  r©. p. pV P                   EFP  pVP                  ;R8X  d’    \        P
                  P                  WvP
                  4      pV
'       d   V
 RVP
                   2MVP
                  pV'       d'   \        RVP
                   RVP                   R24       VP                  WÞ34       K§  ;R8X  di    V
'       d   V
 RVP
                   2MVP
                  pV'       d'   \        RVP
                   RVP                   R24       VP                  V4       EK  R8X  g   EK  V'       g   EK*  \        R	VP
                   RVP                   R24       EKS  	  V'       g	   V'       d¯   V'       d}   . pV'       d   VP                  R
\!        V4       R24       V'       d   VP                  R\!        V4       R24       VP#                  RP                  V4      P%                  4       4       TP'                  T	T;'       g    RT;'       g    RR7       R# R# V'       Edh   \        V P                  4      pVP                  VP                  r©\        P
                  P                  V P                  4      p\        P(                  ! VRR7       . p. pV P                   EFÉ  pVP                  R8X  dô   \        P
                  P                  WvP
                  4      p\        P(                  ! \        P
                  P+                  V4      RR7       V'       d'   \        RVP
                   RVP                   R24       VP,                  e    VP                  VP,                  V34       KÎ  V
'       d   V
 RVP
                   2MVP
                  pVP                  Wí34       EK  VP                  R8X  dl   \        P
                  P                  WvP
                  4      pV'       d'   \        RVP
                   RVP                   R24       VP                  V4       EK„  VP                  R8X  g   EK˜  V'       g   EK£  \        R	VP
                   RVP                   R24       EKÌ  	  \!        V4      ^ 8”  d9   V'       d   VP#                  R\!        V4       R24       VP/                  V	V4       V'       d'   V'       d   VP#                  R\!        V4       R24       V Fž  p\        P
                  P1                  V4      '       g   K*  \        P2                  ! V4       \        P
                  P+                  V4      pVV8w  g   Kh   \        P4                  ! V4       \        P
                  P+                  V4      pKA  	  R# R#   \6         d     K´  i ; i)zExecute a sync plan.r³   rx   z  Uploading: z (Ú)rµ   z  Deleting: r¶   z  Skipping: z
uploading z filesz	deleting z, N)Úaddrµ   T)Úexist_okr´   z  Downloading: zDownloading z	Deleting z local files)rª   rN   r×   rÓ   r   rT   rS   r  r€   r   r�   r®   r¤   Úprintr¯   rõ   r   rB  Ú
capitalizeÚbatch_bucket_filesÚmakedirsÚdirnamer²   Údownload_bucket_filesÚexistsÚremoveÚrmdirrþ   )rM  r  rr  r>  rK  rL  rÃ   r  rˆ   r…   r¦   Ú	add_filesÚdelete_pathsrX  Úremote_pathr¥   Údownload_filesÚdelete_filesÚ	file_pathÚparents   &&&&                r*   Ú_execute_planr‡  w  s¯  € ä# D§K¡KÓ0Ô0×OÐO´_ÀTÇYÁYÓ5O€IÜ! $§+¡+Ó.×QÐQ´ÀtÇyÁyÓ7QÔ3Q€Kð �oŒoˆÜ# B§G¡GÖ,ñ ÷ €yÜ—W‘W—_‘_ T§[¡[Ó1ˆ
Ü" 4§9¡9Ó-ˆØ"ŸI™I v×':Ñ':�6ð ;=ˆ	Ø"$ˆà—/•/ˆBØ—)‘)ÞÝ!#§¡§¡¨j¿'¹'Ó!B�Jß;A V H¨A¨b¯g©g¨YÑ"7ÀrÇwÁw�KßÜ ¨b¯g©g¨Y°b¸¿¹¸À1ÐEÔFØ×$Ñ$ jÐ%>Ö?Þß;A¸6 V H¨A¨b¯g©g¨YÑ"7ÀrÇwÁw�KßÜ ¨R¯W©W¨I°R¸¿	¹	°{À!ÐDÔEØ ×'Ñ'¨×4ß�VŸwšwÜ˜L¨¯©¨	°°B·I±I°;¸aÐ@×Añ "÷" ŸßØ�ßØ—L‘L :¬c°)«nÐ-=¸VÐ!DÔEßØ—L‘L 9¬S°Ó->Ð,?¸vÐ!FÔGØ—‘˜DŸI™I eÓ,×7Ñ7Ó9Ô:Ø×"Ñ"ØØ×%Ð% Ø#×+Ð+ tð #ö ñ %÷ 
ˆÜ" 4§;¡;Ó/ˆØ"ŸI™I v×':Ñ':�6Ü—W‘W—_‘_ T§Y¡YÓ/ˆ
ô 	�Š�J¨Õ.ð EGˆØ"$ˆà—/•/ˆBØ�y‰y˜JÔ&ÜŸW™WŸ\™\¨*·g±gÓ>�
ä—’œBŸG™GŸO™O¨JÓ7À$ÕGßÜ˜O¨B¯G©G¨9°B°r·y±y°kÀÐCÔDà—>‘>Ò-Ø"×)Ñ)¨2¯>©>¸:Ð*FÖGç;A V H¨A¨b¯g©g¨YÑ"7ÀrÇwÁw�KØ"×)Ñ)¨;Ð*C×DØ—‘˜hÔ&ÜŸW™WŸ\™\¨*·g±gÓ>�
ßÜ˜L¨¯©¨	°°B·I±I°;¸aÐ@ÔAØ×#Ñ# J×/Ø—‘˜f×$¯ªÜ˜ R§W¡W I¨R°·	±	¨{¸!Ð<×=ñ' "ô, ˆ~Ó Ô"ßØ—‘˜l¬3¨~Ó+>Ð*?¸vÐFÔGØ×%Ñ% i°Ô@÷ —lØ�K‰K˜)¤C¨Ó$5Ð#6°lÐCÔDÛ%ˆIÜ�w‰w�~‰~˜i×(Ô(Ü—	’	˜)Ô$äŸ™Ÿ™¨Ó3�Ø 
Ö*ðÜŸš Ô(Ü!#§¡§¡°Ó!8šó &ñU 
øôf #ô Úðús   Ù5ZÚZÚZc                ó(   € V ^8„  d   QhR\         RR/# r[  r\  )r3   s   "r*   r5   r5   ß  s   € ÷ *ñ *œhð *¨4ñ *r-   c                ó  € V P                  4       p\        RV P                   RV P                   24       \        RVR,           24       \        RVR,           24       \        RVR,           24       \        R	VR
,           24       R# )z!Print a summary of the sync plan.zSync plan: z -> z  Uploads: rÍ   z  Downloads: rÎ   z  Deletes: rÏ   z	  Skips: rÐ   N)rÔ   rw  rN   r×   )rM  rÔ   s   & r*   Ú_print_plan_summaryrŠ  ß  s~   € à�l‰l‹n€GÜ	ˆK˜Ÿ™�} D¨¯©¨Ð
4Ô5Ü	ˆK˜ 	Õ*Ð+Ð
,Ô-Ü	ˆM˜' +Õ.Ð/Ð
0Ô1Ü	ˆK˜ 	Õ*Ð+Ð
,Ô-Ü	ˆI�g˜gÕ&Ð'Ð
(Ö)r-   rµ   r.  r-  r<  r/  ÚincludeÚexcludeÚfilter_fromrM  ÚapplyÚdry_runrr  ÚquietÚtokenc          $      óš  € V ^8„  d   QhR\         R,          R\         R,          RRR\        R\        R\        R	\        R
\        R\        \         ,          R,          R\        \         ,          R,          R\         R,          R\         R,          R\         R,          R\        R\        R\        R\        \         ,          R,          R\        /# )r/   rN   Nr×   r  r   rµ   r.  r-  r<  r/  r‹  rŒ  r�  rM  rŽ  r�  rr  r�  r‘  rI   )r0   r1   rÙ   r¹   )r3   s   "r*   r5   r5   î  sÿ   € ÷ uñ uÜ�$�Jðuä
��*ðuð 
ð	uô
 ðuô ðuô ðuô ðuô ðuô ”#�Y˜Õðuô ”#�Y˜Õðuô �t•ðuô ��*ðuô ��:ðuô ðuô  ð!uô" ð#uô$ ”#�:˜Õð%uô& ñ'ur-   c               ó.	  € VeG   ^RI Hp V! VP                  VVP                  VP                  VP
                  VP                  R7      pV'       EdX   V '       g	   V'       d   \        R4      hVe   \        R4      hV'       d   \        R4      hV'       d   \        R4      hV'       d   \        R4      hV'       d   \        R	4      hV	'       d   \        R
4      hV
'       d   \        R4      hV'       d   \        R4      hV'       d   \        R4      hV'       d   \        R4      h\        V4      p\        V'       * R7      pV'       g   \        V4       \        R4       V'       d   \        4         \        VW.VR7       V'       d   \        4        T'       g   \        R4       T# V '       d	   V'       g   \        R4      h\        V 4      p\        V4      pV'       d   V'       d   \        R4      hV'       g   V'       g   \        R4      hV'       d   V'       d   \        R4      hV'       d   V'       d   \        R4      hV'       d   V'       d   \        R4      hV'       dZ   \         P"                  P%                  V4      '       d4   \         P"                  P'                  V4      '       g   \        RV 24      hM3\         P"                  P'                  V 4      '       g   \        RV  24      hRpV
'       d   \)        V
4      p\+        VV	VR7      p\        V'       * ;'       d    V'       * R7      p\-        V VVVVVVVVVR7
      pV'       d   \/        V\0        P2                  4       V# V'       d0   \5        VV4       V'       g   \        V4       \        RV 24       V# V'       g   \        V4       VP7                  4       pVR,          ^ 8X  d2   VR,          ^ 8X  d$   VR ,          ^ 8X  d   V'       g   \        R!4       V# V'       g   \        R"4       V'       d   \        4         \        VW.VR7       V'       d   \        4        T'       g   \        R4       T#   T'       d   \        4        i i ; i  T'       d   \        4        i i ; i)#a  Sync files between a local directory and a bucket.

This is equivalent to the ``hf buckets sync`` CLI command. One of ``source`` or ``dest`` must be a bucket path
(``hf://buckets/...``) and the other must be a local directory path.

Args:
    source (`str`, *optional*):
        Source path: local directory or ``hf://buckets/namespace/bucket_name(/prefix)``.
        Required unless using ``apply``.
    dest (`str`, *optional*):
        Destination path: local directory or ``hf://buckets/namespace/bucket_name(/prefix)``.
        Required unless using ``apply``.
    api ([`HfApi`]):
        The HfApi instance to use for API calls.
    delete (`bool`, *optional*, defaults to `False`):
        Delete destination files not present in source.
    ignore_times (`bool`, *optional*, defaults to `False`):
        Skip files only based on size, ignoring modification times.
    ignore_sizes (`bool`, *optional*, defaults to `False`):
        Skip files only based on modification times, ignoring sizes.
    existing (`bool`, *optional*, defaults to `False`):
        Skip creating new files on receiver (only update existing files).
    ignore_existing (`bool`, *optional*, defaults to `False`):
        Skip updating files that exist on receiver (only create new files).
    include (`list[str]`, *optional*):
        Include files matching patterns (fnmatch-style).
    exclude (`list[str]`, *optional*):
        Exclude files matching patterns (fnmatch-style).
    filter_from (`str`, *optional*):
        Path to a filter file with include/exclude rules.
    plan (`str`, *optional*):
        Save sync plan to this JSONL file instead of executing.
    apply (`str`, *optional*):
        Apply a previously saved plan file. When set, ``source`` and ``dest`` are not needed.
    dry_run (`bool`, *optional*, defaults to `False`):
        Print sync plan to stdout as JSONL without executing.
    verbose (`bool`, *optional*, defaults to `False`):
        Show detailed per-file operations.
    quiet (`bool`, *optional*, defaults to `False`):
        Suppress all output and progress bars.
    token (Union[bool, str, None], optional):
        A valid user access token. If not provided, the locally saved token will be used.

Returns:
    [`SyncPlan`]: The computed (or loaded) sync plan.

Raises:
    `ValueError`: If arguments are invalid (e.g., both paths are remote, conflicting options).

Example:
    ```python
    >>> from huggingface_hub import HfApi
    >>> api = HfApi()

    # Upload local directory to bucket
    >>> api.sync_bucket("./data", "hf://buckets/username/my-bucket")

    # Download bucket to local directory
    >>> api.sync_bucket("hf://buckets/username/my-bucket", "./data")

    # Sync with delete and filtering
    >>> api.sync_bucket(
    ...     "./data",
    ...     "hf://buckets/username/my-bucket",
    ...     delete=True,
    ...     include=["*.safetensors"],
    ... )

    # Dry run: preview what would be synced
    >>> plan = api.sync_bucket("./data", "hf://buckets/username/my-bucket", dry_run=True)
    >>> plan.summary()
    {'uploads': 3, 'downloads': 0, 'deletes': 0, 'skips': 1, 'total_size': 4096}

    # Save plan for review, then apply
    >>> api.sync_bucket("./data", "hf://buckets/username/my-bucket", plan="sync-plan.jsonl")
    >>> api.sync_bucket(apply="sync-plan.jsonl")
    ```
Nr   )ry   r‘  Úlibrary_nameÚlibrary_versionÚ
user_agentÚheadersz,Cannot specify source/dest when using apply.z#Cannot specify both plan and apply.z'Cannot specify delete when using apply.z-Cannot specify ignore_times when using apply.z-Cannot specify ignore_sizes when using apply.z(Cannot specify include when using apply.z(Cannot specify exclude when using apply.z,Cannot specify filter_from when using apply.z)Cannot specify existing when using apply.z0Cannot specify ignore_existing when using apply.z(Cannot specify dry_run when using apply.)ÚenabledzExecuting plan...)rr  r>  zSync completed.z7Both source and dest are required (unless using apply).z?Remote to remote sync is not supported. One path must be local.z?One of source or dest must be a bucket path (hf://buckets/...).z2Cannot specify both ignore_times and ignore_sizes.z1Cannot specify both existing and ignore_existing.z%Cannot specify both dry_run and plan.z!Destination must be a directory: z&Source must be an existing directory: rã   )
rN   r×   r  rµ   r.  r-  r<  r/  r=  r>  zPlan saved to: rÍ   rÎ   rÏ   zNothing to sync.z
Syncing...)Úhf_apir   ry   r”  r•  r–  r—  r‚   rp  r   rŠ  rw  r   r‡  r   rª   rS   rT   r}  r	  rù   rÛ   rY  re  ÚsysÚstdoutrj  rÔ   )rN   r×   r  rµ   r.  r-  r<  r/  r‹  rŒ  r�  rM  rŽ  r�  rr  r�  r‘  r   Ú	sync_planr>  Úsource_is_bucketÚdest_is_bucketrß   r=  rÔ   s   &&$$$$$$$$$$$$$$$        r*   Úsync_bucket_internalrŸ  î  s˜  € ðF ÒÝ!áØ—\‘\ØØ×)Ñ)Ø×/Ñ/Ø—~‘~Ø—K‘Kô
ˆ÷ €uß—TÜÐKÓLÐLØÒÜÐBÓCÐCßÜÐFÓGÐGßÜÐLÓMÐMßÜÐLÓMÐMßÜÐGÓHÐHßÜÐGÓHÐHßÜÐKÓLÐLßÜÐHÓIÐIßÜÐOÓPÐPßÜÐGÓHÐHä˜uÓ%ˆ	Ü¨¤IÔ.ˆßÜ 	Ô*ÜÐ%Ô&çÜ!Ô#ð	'Ü˜) SÀ&ÕIçÜ$Ô&çÜÐ#Ô$àÐ÷ ŸÜÐRÓSÐSä& vÓ.ÐÜ$ TÓ*€NçŸNÜÐZÓ[Ð[ç§NÜÐZÓ[Ð[çŸÜÐMÓNÐNç—OÜÐLÓMÐMç—4ÜÐ@ÓAÐA÷ Ü�7‰7�>‰>˜$×Ò¬¯©¯©°d×(;Ò(;ÜÐ@ÀÀÐGÓHÐHøä�w‰w�}‰}˜V×$Ò$ÜÐEÀfÀXÐNÓOÐOð €LßÜ)¨+Ó6ˆä"Ø Ø Ø!ô€Nô  E¤	× 9Ð 9°'¬kÔ:€FÜ"ØØØØØ!Ø!ØØ'Ø%Øô€I÷ Ü�IœsŸz™zÔ*ØÐçÜ�9˜dÔ#ßÜ 	Ô*Ü�O D 6Ð*Ô+ØÐ÷ Ü˜IÔ&à×ÑÓ!€GØˆyÕ˜QÔ 7¨;Õ#7¸1Ô#<ÀÈÕASÐWXÔAXßÜÐ$Ô%ØÐçÜˆlÔçÜÔð#Ü�i ¸fÕEçÜ Ô"çÜÐÔ àÐø÷G Ü$Õ&ð û÷z Ü Õ"ð ús   Å6Q' Ð2Q? Ñ'Q<Ñ?R)FFFFFNN)FN)NN)Gr<   rè   rb  rO   rS   rý   rš  rV   Úcollections.abcr   Údataclassesr   r   r   r   Úpathlibr   Útypingr   r	   r
   rt   r   r   Ú_local_folderr   Úerrorsr   Úutilsr   r   r   r   r   r   r   Úutils._hf_urisr   r™  r   Ú
get_loggerr8   rE  ÚBUCKET_PREFIXr2  r   rB   r_   ri   rn   rs   r�   r˜   r€   rª   r¬   r¹   rÛ   rù   r  r  r  r%  r:  rY  re  rj  rp  r‡  rŠ  rŸ  r"   r-   r*   Ú<module>rª     s‰  ðñó
 Û Û Û 	Û Û 
Û Ý $ß (ß 'Ý ß .Ñ .ç  Ý 6Ý '÷÷ ñ õ /÷ Ýð 
×	Ò	˜HÓ	%€ð  €ØÐ ð ÷'ð 'ó ð'ð@ ÷
ð 
ó ð
ð* ÷-ð -ó ð-ð ÷ð ó ðñ �$Ô÷ð ó ðð  ÷$ð $ó ð$ðN ÷Pð Pó ðPð2 ÷
ð 
ó ð
õ6Cõ,(ð  ÷	*ð 	*ó ð	*ð ÷
ð 
ó ð
÷8.ñ .õbõ:*õ7õ,2õHPð
ESð #÷ES÷Ptõx,õ:õ#÷VeõP*ñuð
 ðuð ðuð ðuð ðuð "ðuð !%ðuð !%ðuð #ðuð ðuð ðuð ðuð  ð!uð" ð#uð$  $÷%uò ur-   