ó
    pyüi+7  ã                   ó  • S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJrJrJr  SSKJr  SS	KJr  S
SKJrJrJrJrJrJr  S
SKJr  S
SKJrJr  \(       a  S
SKJ r   \RB                  " \"5      r#\RH                  " S5      r%Sr&SSS.r'\ " S S5      5       r(\    S9S\\(   S\)S-  S\)S\)S\)S-  S\)S-  S\*\)\)4   S-  S\+\)   S-  S\,\+\*   \+\*   \)S-  4   4S jj5       r- " S S \5      r. " S! S"\5      r/   S:S#S$S%\*S\)S-  S\*\)\)4   S-  S\)S-  SS4S& jjr0S'\*4S( jr1S)\*4S* jr2S+\*4S, jr3S#S$S-\)SS4S. jr4S#S$S/\*S0\5S-\)SS4
S1 jr6S/\*S2\(S0\5S\+\)   4S3 jr7S4\+\*   S5\)S\/4S6 jr8S#S$S7\+\)   S0\5S\+\*   4S8 jr9g);z.Git LFS related type definitions and utilitiesé    N)ÚIterable)Ú	dataclass)Úceil)Úgetsize)ÚTYPE_CHECKINGÚBinaryIOÚ	TypedDict)Úunquote)Ú	constantsé   )Úbuild_hf_headersÚfix_hf_endpoint_in_urlÚhf_raise_for_statusÚhttp_backoffÚloggingÚvalidate_hf_hub_args)ÚSliceFileObj)Úsha256Úsha_fileobj)ÚCommitOperationAddz^[0-9a-f]{40}$zlfs-multipart-uploadzapplication/vnd.git-lfs+json)ÚAcceptzContent-Typec                   ó€   • \ rS rSr% Sr\\S'   \\S'   \\S'   \S\	4S j5       r
\S\4S	 j5       r\S
\4S j5       rSrg)Ú
UploadInfoé6   a<  
Dataclass holding required information to determine whether a blob
should be uploaded to the hub using the LFS protocol or the regular protocol

Args:
    sha256 (`bytes`):
        SHA256 hash of the blob
    size (`int`):
        Size in bytes of the blob
    sample (`bytes`):
        First 512 bytes of the blob
r   ÚsizeÚsampleÚpathc                 ó²   • [        U5      n[        US5       nUR                  S5      S S n[        U5      nS S S 5        U " UWWS9$ ! , (       d  f       N= f)NÚrbé   ©r   r   r   )r   ÚopenÚpeekr   )Úclsr   r   Úfiler   Úshas         ÚP/home/mande/repo/quber/.venv/lib/python3.13/site-packages/huggingface_hub/lfs.pyÚ	from_pathÚUploadInfo.from_pathI   sT   € ä�t‹}ˆÜ�$˜Ô Ø—Y‘Y˜s“^ D SÐ)ˆFÜ˜dÓ#ˆC÷ ñ ˜ S°Ñ8Ð8÷ Õús   ˜ AÁ
AÚdatac                 ó\   • [        U5      R                  5       nU " [        U5      US S US9$ )Nr    )r   r   r   )r   ÚdigestÚlen)r$   r*   r&   s      r'   Ú
from_bytesÚUploadInfo.from_bytesQ   s-   € ä�T‹l×!Ñ!Ó#ˆÙœ˜D›	¨$¨t°¨*¸SÑAÐAó    Úfileobjc                 óè   • UR                  S5      nUR                  S[        R                  5        [	        U5      nUR                  5       nUR                  S[        R                  5        U " XCUS9$ )Nr    r   r!   )ÚreadÚseekÚioÚSEEK_SETr   Útell)r$   r1   r   r&   r   s        r'   Úfrom_fileobjÚUploadInfo.from_fileobjV   sV   € à—‘˜cÓ"ˆØ�‰�QœŸ™Ô$Ü˜'Ó"ˆØ�|‰|‹~ˆØ�‰�QœŸ™Ô$Ù˜°Ñ8Ð8r0   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚbytesÚ__annotations__ÚintÚclassmethodÚstrr(   r.   r   r8   Ú__static_attributes__r:   r0   r'   r   r   6   sj   ‡ ñð ƒMØ
ƒIØƒMàð9˜Só 9ó ð9ð ðB˜eó Bó ðBð ð9 8ó 9ó ó9r0   r   Úupload_infosÚtokenÚ	repo_typeÚrepo_idÚrevisionÚendpointÚheadersÚ	transfersÚreturnc                 ó,  • Ub  UO[         R                  nSnU[         R                  ;   a  [         R                  U   nU SU U S3n	SUb  UOSS/U  V
s/ s H*  n
U
R                  R	                  5       U
R
                  S.PM,     sn
S	S
.nUb  S[        U5      0US'   0 [        E[        US9EU=(       d    0 En[        SX–US9n[        U5        UR                  5       nUR                  SS5      n[        U[        5      (       d  [        S5      eUR                  S5      n[        U[         5      (       a  UOSnU Vs/ s H  nSU;  d  M  [#        U5      PM     snU Vs/ s H  nSU;   d  M  [%        U5      PM     snU4$ s  sn
f s  snf s  snf )a  
Requests the LFS batch endpoint to retrieve upload instructions

Learn more: https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md

Args:
    upload_infos (`Iterable` of `UploadInfo`):
        `UploadInfo` for the files that are being uploaded, typically obtained
        from `CommitOperationAdd.upload_info`
    repo_type (`str`):
        Type of the repo to upload to: `"model"`, `"dataset"` or `"space"`.
    repo_id (`str`):
        A namespace (user or an organization) and a repo name separated
        by a `/`.
    revision (`str`, *optional*):
        The git revision to upload to.
    headers (`dict`, *optional*):
        Additional headers to include in the request
    transfers (`list`, *optional*):
        List of transfer methods to use. Defaults to ["basic", "multipart"].

Returns:
    `LfsBatchInfo`: 3-tuple:
        - First element is the list of upload instructions from the server
        - Second element is a list of errors, if any
        - Third element is the chosen transfer adapter if provided by the server (e.g. "basic", "multipart", "xet")

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If an argument is invalid or the server response is malformed.
    [`HfHubHTTPError`]
        If the server returned an error.
NÚ Ú/z.git/info/lfs/objects/batchÚuploadÚbasicÚ	multipart©Úoidr   r   )Ú	operationrM   ÚobjectsÚ	hash_algoÚnameÚref)rG   ÚPOST©rL   ÚjsonrX   zMalformed response from serverÚtransferÚerror)r   ÚENDPOINTÚREPO_TYPES_URL_PREFIXESr   Úhexr   r
   ÚLFS_HEADERSr   r   r   r^   ÚgetÚ
isinstanceÚlistÚ
ValueErrorrD   Ú_validate_batch_actionsÚ_validate_batch_error)rF   rG   rH   rI   rJ   rK   rL   rM   Ú
url_prefixÚ	batch_urlrR   ÚpayloadÚrespÚ
batch_inforX   Úchosen_transferÚobjs                    r'   Úpost_lfs_batch_inforr   `   s»  € ðX $Ñ/‰x´Y×5GÑ5G€HØ€JØ”I×5Ñ5Ó5Ü×6Ñ6°yÑAˆ
Ø�*˜A˜j˜\¨'¨Ð2MÐN€IàØ"+Ñ"7‘Y¸gÀ{Ð=Sñ 'ó
ò
 '�ð —}‘}×(Ñ(Ó*ØŸ™ôñ 'ñ
ð ñ€Gð ÑØ ¤'¨(Ó"3Ð4ˆ�‰ðÜ
ðä
 Ñ
'ðð �=�bð€Gô
 ˜ 	ÀÑI€DÜ˜ÔØ—‘“€Jà�n‰n˜Y¨Ó-€GÜ�gœt×$Ñ$ÜÐ9Ó:Ð:à —n‘n ZÓ0€OÜ)3°OÄS×)IÑ)I‘oÈt€Oñ 29ÓO²¨#¸GÈ3Ñ<NÓ	%Ô	  Ö	%±ÑOÙ/6ÓIªw¨¸'ÀS¹.Ó	#Ô	˜sÖ	#©wÑIØðð ùò9
ùò: 	PùÚIs   Á1FÅ
FÅFÅ%
FÅ3Fc                   ó*   • \ rS rSr% \\S'   \\S'   Srg)ÚPayloadPartTé·   Ú
partNumberÚetagr:   N)r;   r<   r=   r>   rB   rA   rD   rE   r:   r0   r'   rt   rt   ·   s   ‡ ØƒOØ
†Ir0   rt   c                   ó4   • \ rS rSr% Sr\\S'   \\   \S'   Sr	g)ÚCompletionPayloadTé¼   z?Payload that will be sent to the Hub when uploading multi-part.rV   Úpartsr:   N)
r;   r<   r=   r>   r?   rD   rA   rg   rt   rE   r:   r0   r'   ry   ry   ¼   s   ‡ ÙIà	ƒHØ�ÑÖr0   ry   rW   r   Úlfs_batch_actionc           	      ó  • [        U5        UR                  S5      nUc$  [        R                  SU R                   S35        gUS   S   n[        U5        US   R                  S5      nUb  [        U5        UR                  S0 5      nUR                  S5      n	[        US	   US
9n
U	b   [        U	5      n	[        XXšS9  O	[        X
S9  Ubq  [        U5        [        US	   U5      n[        SU[        X#S9U R                  R                  R!                  5       U R                  R"                  S.S9n[%        U5        [        R                  U R                   S35        g! [        [        4 a    [        SU	 S35      ef = f)aù  
Handles uploading a given object to the Hub with the LFS protocol.

Can be a No-op if the content of the file is already present on the hub large file storage.

Args:
    operation (`CommitOperationAdd`):
        The add operation triggering this upload.
    lfs_batch_action (`dict`):
        Upload instructions from the LFS batch endpoint for this object. See [`~utils.lfs.post_lfs_batch_info`] for
        more details.
    headers (`dict`, *optional*):
        Headers to include in the request, including authentication and user agent headers.

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If `lfs_batch_action` is improperly formatted
    [`HfHubHTTPError`]
        If the upload resulted in an error
ÚactionsNzContent of file z. is already present upstream - skipping uploadrR   ÚverifyÚheaderÚ
chunk_sizeÚhref)rK   zTMalformed response from LFS batch endpoint: `chunk_size` should be an integer. Got 'z'.)rW   r€   r�   Ú
upload_url)rW   rƒ   r\   )rG   rL   rU   r]   z: Upload successful)ri   re   ÚloggerÚdebugÚpath_in_repoÚ_validate_lfs_actionr   rB   rh   Ú	TypeErrorÚ_upload_multi_partÚ_upload_single_partr   r   Úupload_infor   rc   r   r   )rW   r|   rG   rL   rK   r~   Úupload_actionÚverify_actionr€   r�   rƒ   Ú
verify_urlÚverify_resps                r'   Ú
lfs_uploadr�   Ã   s“  € ô8 Ð,Ô-Ø×"Ñ" 9Ó-€GØ�ä�‰Ð'¨	×(>Ñ(>Ð'?Ð?mÐnÔoØð % YÑ/°Ñ9€MÜ˜Ô'Ø$ YÑ/×3Ñ3°HÓ=€MØÑ Ü˜]Ô+ð ×Ñ˜x¨Ó,€FØ—‘˜LÓ)€JÜ'¨°fÑ(=ÈÑQ€JØÑð	Ü˜Z›ˆJô
 	 YÈ*Ólä iÒGð Ñ Ü˜]Ô+Ü+¨M¸&Ñ,AÀ8ÓLˆ
Ü"ØØÜ$¨5ÑBØ"×.Ñ.×5Ñ5×9Ñ9Ó;ÀY×EZÑEZ×E_ÑE_Ñ`ñ	
ˆô 	˜KÔ(Ü
‡L�L�I×*Ñ*Ð+Ð+>Ð?Õ@øô' œIÐ&ó 	ÜØfÐgqÐfrÐrtÐuóð ð	ús   Â-E# Å# FÚ
lfs_actionc                 óÐ   • [        U R                  S5      [        5      (       a6  U R                  S5      b/  [        U R                  S5      [        5      (       d  [	        S5      eU $ )ú.validates response from the LFS batch endpointr‚   r€   z"lfs_action is improperly formatted)rf   re   rD   Údictrh   )r‘   s    r'   r‡   r‡   
  sQ   € ô 	�:—>‘> &Ó)¬3×/Ñ/Ø�^‰^˜HÓ%Ñ-´¸J¿N¹NÈ8Ó<TÔVZ×1[Ñ1[äÐ=Ó>Ð>ØÐr0   Úlfs_batch_actionsc                 óh  • [        U R                  S5      [        5      (       a$  [        U R                  S5      [        5      (       d  [	        S5      eU R                  S0 5      R                  S5      nU R                  S0 5      R                  S5      nUb  [        U5        Ub  [        U5        U $ )r“   rV   r   z)lfs_batch_actions is improperly formattedr~   rR   r   )rf   re   rD   rB   rh   r‡   )r•   rŒ   r�   s      r'   ri   ri     s�   € äÐ(×,Ñ,¨UÓ3´S×9Ñ9¼jÐIZ×I^ÑI^Ð_eÓIfÔhk×>lÑ>lÜÐDÓEÐEà%×)Ñ)¨)°RÓ8×<Ñ<¸XÓF€MØ%×)Ñ)¨)°RÓ8×<Ñ<¸XÓF€MØÑ Ü˜]Ô+ØÑ Ü˜]Ô+ØÐr0   Úlfs_batch_errorc                 óž  • [        U R                  S5      [        5      (       a$  [        U R                  S5      [        5      (       d  [	        S5      eU R                  S5      n[        U[
        5      (       aH  [        UR                  S5      [        5      (       a$  [        UR                  S5      [        5      (       d  [	        S5      eU $ )r“   rV   r   z'lfs_batch_error is improperly formattedr`   ÚmessageÚcode)rf   re   rD   rB   rh   r”   )r—   Ú
error_infos     r'   rj   rj   "  sš   € ä�×*Ñ*¨5Ó1´3×7Ñ7¼JÀ×GZÑGZÐ[aÓGbÔdg×<hÑ<hÜÐBÓCÐCØ ×$Ñ$ WÓ-€Jä�:œt×$Ñ$Ü�z—~‘~ iÓ0´#×6Ñ6Ü�z—~‘~ fÓ-¬s×3Ñ3äÐBÓCÐCØÐr0   rƒ   c                 ó€   • U R                  SS9 n[        SXS9n[        U5        SSS5        g! , (       d  f       g= f)a#  
Uploads `fileobj` as a single PUT HTTP request (basic LFS transfer protocol)

Args:
    upload_url (`str`):
        The URL to PUT the file to.
    fileobj:
        The file-like object holding the data to upload.

Raises:
    [`HfHubHTTPError`]
        If the upload resulted in an error.
T©Ú	with_tqdmÚPUT©r*   N)Úas_filer   r   )rW   rƒ   r1   Úresponses       r'   rŠ   rŠ   0  s7   € ð 
×	Ñ	 TÐ	Ñ	*¨gä  zÑ@ˆÜ˜HÔ%÷ 
+×	*Ö	*ús   �/¯
=r€   r�   c           	      óÌ   • [        XR                  US9n[        XUS9n[        SU[	        XPR                  R
                  R                  5       5      [        S9n[        U5        g)z8
Uploads file using HF multipart LFS transfer protocol.
)r€   r‹   r�   )rW   Úsorted_parts_urlsr�   r\   )r^   rL   N)	Ú_get_sorted_parts_urlsr‹   Ú_upload_parts_iterativelyr   Ú_get_completion_payloadr   rc   rd   r   )rW   r€   r�   rƒ   r¤   Úresponse_headersÚcompletion_ress          r'   r‰   r‰   D  sg   € ô
 /°f×J_ÑJ_ÐlvÑwÐô 1ØÈZñÐô "ØØÜ$Ð%5×7LÑ7L×7SÑ7S×7WÑ7WÓ7YÓZÜñ	€Nô ˜Õ'r0   r‹   c           
      ón  • [        U R                  5        VVs/ s H;  u  p4UR                  5       (       d  M  [        U5      S:”  d  M-  [	        US5      U4PM=     snnS S9 VVs/ s H  u  pTUPM	     nnn[        U5      nU[        UR                  U-  5      :w  a  [        S5      eU$ s  snnf s  snnf )Nr   é
   c                 ó   • U S   $ )Nr   r:   )Úts    r'   Ú<lambda>Ú(_get_sorted_parts_urls.<locals>.<lambda>d  s   € ˜!˜Aš$r0   )Úkeyz0Invalid server response to upload large LFS file)ÚsortedÚitemsÚisdigitr-   rB   r   r   rh   )r€   r‹   r�   Úpart_numrƒ   Ú_Úsorted_part_upload_urlsÚ	num_partss           r'   r¥   r¥   [  sÆ   € ô $ð -3¯L©L¬Nôâ,:Ñ(�HØ×#Ñ#×%ó 0ä*-¨h«-¸!Ñ*;ó 0”�X˜rÓ" JÓ/Ù,:òñ
 ò
ô
ò
‰MˆAó 	ñ
ð ñ 
ô Ð+Ó,€IØ”D˜×)Ñ)¨JÑ6Ó7Ó7ÜÐKÓLÐLØ"Ð"ùóùó
s   ™B+
¸B+
Á	B+
Á&B1r¨   rV   c                 óÀ   • / n[        U 5       HJ  u  p4UR                  S5      nUb  US:X  a  [        SU SUS-    35      eUR                  US-   US.5        ML     XS.$ )Nrw   rP   zInvalid etag (`z`) returned for part r   )rv   rw   )rV   r{   )Ú	enumeratere   rh   Úappend)r¨   rV   r{   Úpart_numberr€   rw   s         r'   r§   r§   m  sx   € Ø "€EÜ(Ð)9Ö:ÑˆØ�z‰z˜&Ó!ˆØ‰<˜4 2›:Ü˜¨t¨fÐ4IÈ+ÐXYÉ/ÐIZÐ[Ó\Ð\Ø�‰à)¨A™oØñö	
ñ	  ;ð Ñ'Ð'r0   r¤   c           	      ó6  • / nU R                  SS9 n[        U5       HK  u  pV[        UX%-  US9 n[        SXgS9n[	        U5        UR                  UR                  5        S S S 5        MM     S S S 5        U$ ! , (       d  f       Mh  = f! , (       d  f       U$ = f)NTr�   )Ú	seek_fromÚ
read_limitrŸ   r    )r¡   r¹   r   r   r   rº   rL   )	rW   r¤   r�   rL   r1   Úpart_idxÚpart_upload_urlÚfileobj_sliceÚpart_upload_ress	            r'   r¦   r¦   |  s    € ð €GØ	×	Ñ	 TÐ	Ñ	*¨gÜ)2Ð3DÖ)EÑ%ˆHÜØØ$Ñ/Ø%òð ä".¨u°oÑ"Z�Ü# OÔ4Ø—‘˜×6Ñ6Ô7÷ñ ñ *F÷ 
+ð €N÷ö ú÷ 
+Ô	*ð €Nús"   ’B	°1A7Á!B	Á7
BÂB	Â	
B)NNNN)NNN):r?   r5   ÚreÚcollections.abcr   Údataclassesr   Úmathr   Úos.pathr   Útypingr   r   r	   Úurllib.parser
   Úhuggingface_hubr   Úutilsr   r   r   r   r   r   Ú
utils._lfsr   Ú	utils.shar   r   Ú_commit_apir   Ú
get_loggerr;   r„   ÚcompileÚ	OID_REGEXÚLFS_MULTIPART_UPLOAD_COMMANDrd   r   rD   r”   rg   Útuplerr   rt   ry   r�   r‡   ri   rj   rŠ   rB   r‰   r¥   r§   r¦   r:   r0   r'   Ú<module>rÔ      s¶  ðñ 5ã 	Û 	Ý $Ý !Ý Ý ß 5Ñ 5Ý  å %÷÷ õ %ß *ö Ý/à	×	Ò	˜HÓ	%€à�JŠJÐ(Ó)€	à5Ð ð -Ø2ñ€ð ÷&9ð &9ó ð&9ðR ð  ØØ%)Ø"&ñSØ˜:Ñ&ðSà�‰:ðSð ðSð ð	Sð
 �D‰jðSð �D‰jðSð �#�s�(‰^˜dÑ"ðSð �C‰y˜4ÑðSð ˆ4�‰:�t˜D‘z 3¨¡:Ð-Ñ.ôSó ðSôl�9ô ô
˜ô ð Ø%)ØñDAØ#ðDAàðDAð �‰:ðDAð �#�s�(‰^˜dÑ"ð	DAð
 �D‰jðDAð 
õDAðN Tô ð¨tô ð¨4ô ð&Ð#7ð &ÀSð &ÈTô &ð((Ð"6ð (Àð (ÐRUð (Ðcfð (Ðkoô (ð.# 4ð #°jð #Ècð #ÐVZÐ[^ÑV_ô #ð$(¨d°4©jð (¸sð (ÐGYô (ðØ#ðØ8<¸S¹	ðØORðà	ˆ$�Zõr0   