+
    &j:                        R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt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 ^R
IHt ^RIHtHt ]'       d   ^RIH t  ]PB                  ! ]"4      t#]PH                  ! R4      t%Rt&RRRR/t'] ! R R4      4       t(]R,R R ll4       t) ! R R]4      t* ! R R]4      t+R-R R llt,R R lt-R R lt.R  R! lt/R" R# lt0R$ R% lt1R& R' lt2R( R) lt3R* R+ lt4R# ).z.Git LFS related type definitions and utilitiesN)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-uploadAcceptzapplication/vnd.git-lfs+jsonzContent-Typec                      a  ] tR t^6t o Rt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tV 3R lt	R	t
V tR
# )
UploadInfoa<  
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
c                    < V ^8  d   QhRS[ /# )   pathstr)format__classdict__s   "k/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/huggingface_hub/lfs.py__annotate__UploadInfo.__annotate__J   s     9 9S 9    c                    \        V4      p\        VR 4      ;_uu_ 4       pVP                  R4      R,          p\        V4      pRRR4       V ! VXXR7      #   + '       g   i     L; i)rb   Ni   NNsizer   sample)r   openpeekr   )clsr   r(   filer)   shas   &&    r   	from_pathUploadInfo.from_pathI   sU    t}$YYs^D)Fd#C  S88 s   $AA'	c                    < V ^8  d   QhRS[ /# )r   data)bytes)r   r   s   "r   r    r!   R   s     B Be Br"   c                j    \        V4      P                  4       pV ! \        V4      VR ,          VR7      # )r&   )r(   r)   r   )r   digestlen)r,   r2   r.   s   && r   
from_bytesUploadInfo.from_bytesQ   s+    Tl!!#D	$t*SAAr"   c                    < V ^8  d   QhRS[ /# )r   fileobj)r   )r   r   s   "r   r    r!   W   s     9 98 9r"   c                    VP                  R 4      pVP                  ^ \        P                  4       \	        V4      pVP                  4       pVP                  ^ \        P                  4       V ! WCVR7      # )r%   r'   )readseekioSEEK_SETr   tell)r,   r:   r)   r.   r(   s   &&   r   from_fileobjUploadInfo.from_fileobjV   sV    c"Q$'"||~Q$88r"   c                >   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   # )r   r   r(   r)   )r3   int)r   r   s   "r   r    r!   6   s)      M   I! " M# r"    N)__name__
__module____qualname____firstlineno____doc__classmethodr/   r7   rA   __annotate_func____static_attributes____classdictcell__r   s   @r   r   r   6   sP     " 9 9 B B 9 9C  r"   r   c                ~   V ^8  d   QhR\         \        ,          R\        R,          R\        R\        R\        R,          R\        R,          R\        \        \        3,          R,          R	\        \        ,          R,          R
\
        \        \        ,          \        \        ,          \        R,          3,          /	# )r   upload_infostokenN	repo_typerepo_idrevisionendpointheaders	transfersreturn)r   r   r   dictlisttuple)r   s   "r   r    r    a   s     X X:&X:X X 	X
 DjX DjX #s(^d"X Cy4X 4:tDz3:-.Xr"   c                T   Ve   TM\         P                  pRpV\         P                  9   d   \         P                  V,          pV RV V R2p	RRRVe   TMRR	.R
V  U
u. uF+  p
RV
P                  P	                  4       RV
P
                  /NK-  	  up
RR/pVe   R\        V4      /VR&   / \        C\        VR7      CT;'       g    / Cp\        RWVR7      p\        V4       VP                  4       pVP                  R
R4      p\        V\        4      '       g   \        R4      hVP                  R4      p\        V\         4      '       d   TMRpV Uu. uF  pRV9  g   K  \#        V4      NK  	  upV Uu. uF  pRV9   g   K  \%        V4      NK  	  upV3# u up
i u upi u upi )aa  
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`
    token (`str` or `None`):
        An authentication token (see https://huggingface.co/settings/token).
        Pass `None` to fall back to the local cached token (or no token if unauthenticated).
    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.
    endpoint (`str`, *optional*):
        The Hub endpoint to send the request to. Defaults to the value of `HF_ENDPOINT`.
    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	operationuploadrX   basic	multipartobjectsoidr(   	hash_algor   nameref)rR   POSTrW   jsonzMalformed response from servertransfererror)r
   ENDPOINTREPO_TYPES_URL_PREFIXESr   hexr(   r	   LFS_HEADERSr   r   r   rk   get
isinstancer[   
ValueErrorr   _validate_batch_actions_validate_batch_error)rQ   rR   rS   rT   rU   rV   rW   rX   
url_prefix	batch_urlra   payloadresp
batch_inford   chosen_transferobjs   &&&&&&&&         r   post_lfs_batch_infor~   `   s   b $/xY5G5GHJI55566yA
*Aj\'2MNIX)"7Yg{=S
 '

 ' v}}((* '
 	XG  '("34


' ==bG
 	IDJnnY-Ggt$$9:: nnZ0O)3OS)I)IotO 29O#G3<N	%	 	%O/6Iw'S.	#	s	#wI 9
: 	PIs    1F	F $F 9	F%F%c                   ,   a  ] tR t^t o V 3R ltRtV tR# )PayloadPartTc                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r   
partNumberetag)rD   r   )r   r   s   "r   r    PayloadPartT.__annotate__   s     O 
I r"   rE   N)rF   rG   rH   rI   rL   rM   rN   rO   s   @r   r   r      s      r"   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )CompletionPayloadTz?Payload that will be sent to the Hub when uploading multi-part.c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # )r   re   parts)r   r[   r   )r   r   s   "r   r    CompletionPayloadT.__annotate__   s#      
H  	 r"   rE   N)rF   rG   rH   rI   rJ   rL   rM   rN   rO   s   @r   r   r      s     I  r"   r   c                    V ^8  d   QhRRR\         R\        R,          R\         \        \        3,          R,          R\        R,          RR/# )	r   r`   r   lfs_batch_actionrR   NrW   rV   rY   )rZ   r   )r   s   "r   r    r       si     JA JA#JAJA :JA #s(^d"	JA
 DjJA 
JAr"   c           	     b   \        V4       VP                  R4      pVf&   \        P                  RV P                   R24       R# VR,          R,          p\        V4       VR,          P                  R4      pVe   \        V4       VP                  R/ 4      pVP                  R4      p	\        VR	,          VR
7      p
V	e    \        V	4      p	\        YYR7       M\        W
R7       Ve}   \        V4       \        VR	,          V4      p\        RV\        W#R7      RV P                  P                  P!                  4       RV P                  P"                  /R7      p\%        V4       \        P                  V P                   R24       R#   \        \        3 d    \        RT	 R24      hi ; i)ae  
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.
    token (`str`, *optional*):
        An authentication token (see https://huggingface.co/settings/token). Used to call the
        optional LFS verify step at the end of the upload. If `None`, falls back to the local
        cached token.
    headers (`dict`, *optional*):
        Headers to include in the request, including authentication and user agent headers.
    endpoint (`str`, *optional*):
        The Hub endpoint to send the request to. Defaults to the value of `HF_ENDPOINT`.

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 uploadra   verifyheader
chunk_sizehref)rV   zTMalformed response from LFS batch endpoint: `chunk_size` should be an integer. Got 'z'.)r`   r   r   
upload_url)r`   r   ri   )rR   rW   re   r(   rj   z: Upload successful)ru   rr   loggerdebugpath_in_repo_validate_lfs_actionr   rD   rt   	TypeError_upload_multi_part_upload_single_partr   r   upload_infor   rp   r(   r   )r`   r   rR   rW   rV   r   upload_actionverify_actionr   r   r   
verify_urlverify_resps   &&&&&        r   
lfs_uploadr      s   D ,-""9-G'	(>(>'??mno %Y/9M'$Y/33H=M ]+ x,FL)J'f(=QJ	ZJ
 	Y*liG  ]++M&,A8L
"$5B..5599;VYEZEZE_E_`	
 	K(
LLI**++>?@' I& 	fgqfrrtu 	s   F !F.c                $    V ^8  d   QhR\         /# )r   
lfs_actionrZ   )r   s   "r   r    r      s      T r"   c                    \        V P                  R4      \        4      '       d9   V P                  R4      e1   \        V P                  R4      \        4      '       g   \	        R4      hV # ).validates response from the LFS batch endpointr   r   z"lfs_action is improperly formatted)rs   rr   r   rZ   rt   )r   s   &r   r   r     sQ     	:>>&)3//^^H%-JNN8<TVZ1[1[=>>r"   c                $    V ^8  d   QhR\         /# )r   lfs_batch_actionsr   )r   s   "r   r    r      s      t r"   c                p   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R/ 4      P                  R4      pV P                  R/ 4      P                  R4      pVe   \        V4       Ve   \        V4       V # )r   re   r(   z)lfs_batch_actions is improperly formattedr   ra   r   )rs   rr   r   rD   rt   r   )r   r   r   s   &  r   ru   ru     s    (,,U3S99jIZI^I^_eIfhk>l>lDEE%)))R8<<XFM%)))R8<<XFM ]+ ]+r"   c                $    V ^8  d   QhR\         /# )r   lfs_batch_errorr   )r   s   "r   r    r    -  s      4 r"   c                   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R4      p\        V\
        4      '       dK   \        VP                  R4      \        4      '       d&   \        VP                  R4      \        4      '       g   \	        R4      hV # )r   re   r(   z'lfs_batch_error is improperly formattedrm   messagecode)rs   rr   r   rD   rt   rZ   )r   
error_infos   & r   rv   rv   -  s    **51377JGZGZ[aGbdg<h<hBCC $$W-J:t$$z~~i0#66z~~f-s33BCCr"   c                ,    V ^8  d   QhRRR\         RR/# )r   r`   r   r   rY   Nr   )r   s   "r   r    r    ;  s"     & &#7 &S &T &r"   c                    V P                  RR7      ;_uu_ 4       p\        RWR7      p\        V4       RRR4       R#   + '       g   i     R# ; i)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r2   N)as_filer   r   )r`   r   r:   responses   &&  r   r   r   ;  s=     
		T		*	*gz@H% 
+	*	*	*s	   >A	c          
      D    V ^8  d   QhRRR\         R\        R\        RR/# )r   r`   r   r   r   r   rY   N)rZ   rD   r   )r   s   "r   r    r    O  s3     ( ("6 ( (RU (cf (ko (r"   c           	         \        WP                  VR7      p\        WVR7      p\        RV\	        WPP                  P
                  P                  4       4      \        R7      p\        V4       R# )z8
Uploads file using HF multipart LFS transfer protocol.
)r   r   r   )r`   sorted_parts_urlsr   ri   )rk   rW   N)	_get_sorted_parts_urlsr   _upload_parts_iterativelyr   _get_completion_payloadr   rp   rq   r   )r`   r   r   r   r   response_headerscompletion_ress   &&&&   r   r   r   O  sg    
 /fJ_J_lvw 1Z "$%57L7L7S7S7W7W7YZ	N 'r"   c          	      ^    V ^8  d   QhR\         R\        R\        R\        \        ,          /# )r   r   r   r   rY   )rZ   r   rD   r[   r   )r   s   "r   r    r    f  s/     # #4 #j #c #VZ[^V_ #r"   c           
      ~   \        V P                  4        UUu. uF=  w  r4VP                  4       '       g   K  \        V4      ^ 8  g   K/  \	        V^
4      V3NK?  	  uppR R7       UUu. uF  w  rTVNK	  	  ppp\        V4      pV\        VP                  V,          4      8w  d   \        R4      hV# u uppi u uppi )    c                     V ^ ,          # )r   rE   )ts   &r   <lambda>(_get_sorted_parts_urls.<locals>.<lambda>o  s    !A$r"   )keyz0Invalid server response to upload large LFS file)sorteditemsisdigitr6   rD   r   r(   rt   )r   r   r   part_numr   _sorted_part_upload_urls	num_partss   &&&     r   r   r   f  s     $ -3LLN,:(H##% 0*-h-!*; 0Xr"J/,:
 


MA 	
  
 +,ID))J677KLL""
s   B3
B3

B3
*B9c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r   r   re   rY   )r[   rZ   r   r   )r   s   "r   r    r    x  s&     ( (d4j (s (GY (r"   c                     . p\        V 4       FU  w  r4VP                  R 4      pVe   VR8X  d   \        RV RV^,            24      hVP                  RV^,           R V/4       KW  	  RVRV/# )r   r^   zInvalid etag (`z`) returned for part r   re   r   )	enumeraterr   rt   append)r   re   r   part_numberr   r   s   &&    r   r   r   x  s     "E()9:zz&!<42:tf4I+XY/IZ[\\kAo	
	  ; 3''r"   c          	      l    V ^8  d   QhRRR\         \        ,          R\        R\         \        ,          /# )r   r`   r   r   r   rY   )r[   r   rD   rZ   )r   s   "r   r    r      s4      #8<S	OR	$Zr"   c                 x   . pV P                  R R7      ;_uu_ 4       p\        V4       F]  w  rV\        VW%,          VR7      ;_uu_ 4       p\        RWgR7      p\	        V4       VP                  VP                  4       RRR4       K_  	  RRR4       V#   + '       g   i     K|  ; i  + '       g   i     T# ; i)Tr   )	seek_from
read_limitr   r   N)r   r   r   r   r   r   rW   )	r`   r   r   rW   r:   part_idxpart_upload_urlfileobj_slicepart_upload_ress	   &&&      r   r   r     s     G			T		*	*g)23D)E%H$/%  ".uo"Z#O4667  *F 
+ N   
+	* Ns#   -B(
4B>B(B%	B((B9	)NNNN)NNN)5rJ   r>   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_loggerrF   r   compile	OID_REGEXLFS_MULTIPART_UPLOAD_COMMANDrq   r   r~   r   r   r   r   ru   rv   r   r   r   r   r   rE   r"   r   <module>r      s    5 	 	 $ !   5 5   %  % * /			H	%JJ()	5  ,2 &9 &9 &9R X Xv9 
 JAZ&((.#$(r"   