§
    «˜ºhÕ  ã                   ó–  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZmZ dd	lmZmZ dd
lmZ ddlm Z m!Z!m"Z"m#Z#m$Z$m%Z% ddl&m'Z'  e"j(        e)¦  «        Z* G d„ d¦  «        Z+dee,e	f         de-fd„Z.dee,e	f         de,de-fd„Z/dee,e	f         de-fd„Z0dee,e	f         de-fd„Z1dee,e	f         de-fd„Z2d#de,dee,e	df         dee,         fd„Z3dee,e	f         de-fd„Z4d$dee,e	f         dee,         de5fd„Z6 G d„ de¦  «        Z7ed „ ¦   «         Z8 G d!„ d"¦  «        Z9dS )%é    N)Úcontextmanager)ÚPath)ÚCallableÚDictÚIteratorÚListÚOptionalÚTupleÚ	TypedDictÚUnion)Úurlparse)Ú	constants)Úmetadata_loadÚmetadata_saveé   )ÚHfApiÚrepo_type_and_id_from_hf_id)ÚLFS_MULTIPART_UPLOAD_COMMAND)ÚSoftTemporaryDirectoryÚ	get_tokenÚloggingÚrun_subprocessÚtqdmÚvalidate_hf_hub_args)Ú_deprecate_methodc                   óÚ   — e Zd ZdZ	 ddedededej        dee         f
d„Z	e
d	efd
„¦   «         Ze
d	efd„¦   «         Ze
d	efd„¦   «         Ze
d	efd„¦   «         Ze
d	efd„¦   «         Zd„ ZdS )ÚCommandInProgressz=
    Utility to follow commands launched asynchronously.
    NÚtitleÚis_done_methodÚstatus_methodÚprocessÚpost_methodc                 óh   — || _         || _        || _        || _        d| _        d| _        || _        d S )NÚ )r   Ú_is_doneÚ_statusÚ_processÚ_stderrÚ_stdoutÚ_post_method)Úselfr   r   r    r!   r"   s         úb/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/huggingface_hub/repository.pyÚ__init__zCommandInProgress.__init__$   s<   € ð ˆŒ
Ø&ˆŒØ$ˆŒØˆŒØˆŒØˆŒØ'ˆÔÐÐó    Úreturnc                 óv   — |                       ¦   «         }|r"| j        �|                      ¦   «          d| _        |S )z.
        Whether the process is done.
        N)r%   r*   )r+   Úresults     r,   Úis_donezCommandInProgress.is_done4   s@   € ð
 —’‘”ˆàð 	%�dÔ'Ð3Ø×ÒÑÔÐØ $ˆDÔàˆr.   c                 ó*   — |                       ¦   «         S )zü
        The exit code/status of the current action. Will return `0` if the
        command has completed successfully, and a number between 1 and 255 if
        the process errored-out.

        Will return -1 if the command is still ongoing.
        )r&   ©r+   s    r,   ÚstatuszCommandInProgress.statusA   s   € ð �|Š|‰~Œ~Ðr.   c                 ó   — | j         dk    S )z2
        Whether the process errored-out.
        r   ©r5   r4   s    r,   ÚfailedzCommandInProgress.failedL   s   € ð
 Œ{˜QŠÐr.   c                 ó€   — | j         j        �,| xj        | j         j                             ¦   «         z  c_        | j        S )zC
        The current output message on the standard error.
        )r'   Ústderrr(   Úreadr4   s    r,   r:   zCommandInProgress.stderrS   ó8   € ð
 Œ=ÔÐ+ØˆLŒL˜DœMÔ0×5Ò5Ñ7Ô7Ñ7ˆLŒLØŒ|Ðr.   c                 ó€   — | j         j        �,| xj        | j         j                             ¦   «         z  c_        | j        S )zD
        The current output message on the standard output.
        )r'   Ústdoutr)   r;   r4   s    r,   r>   zCommandInProgress.stdout\   r<   r.   c           	      ón   — | j         }|dk    rd}d| j        › d|› d| j        sdnd› d| j        j        › d	�	S )
NéÿÿÿÿÚrunningú[z command, status code: z, zin progress.z	finished.z PID: ú])r5   r   r2   r'   Úpid)r+   r5   s     r,   Ú__repr__zCommandInProgress.__repr__e   sj   € Ø”ˆà�RŠ<ˆ<ØˆFð%�”
ð %ð %°6ð %ð %Ø&*¤lÐC��¸ð%ð %à”Ô!ð%ð %ð %ð	
r.   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   Ú
subprocessÚPopenr	   r-   ÚpropertyÚboolr2   Úintr5   r8   r:   r>   rE   © r.   r,   r   r      sF  € € € € € ðð ð +/ð(ð (àð(ð !ð(ð  ð	(ð
 Ô!ð(ð ˜hÔ'ð(ð (ð (ð (ð  ð
˜ð 
ð 
ð 
ñ „Xð
ð ð˜ð ð ð ñ „Xðð ð˜ð ð ð ñ „Xðð ð˜ð ð ð ñ „Xðð ð˜ð ð ð ñ „Xðð

ð 

ð 

ð 

ð 

r.   r   Úfolderr/   c                 ó  — t           j                             t           j                             | d¦  «        ¦  «        }t	          j        d                     ¦   «         | t          j        t          j        ¬¦  «        }|o
|j        dk    S )a  
    Check if the folder is the root or part of a git repository

    Args:
        folder (`str`):
            The folder in which to run the command.

    Returns:
        `bool`: `True` if the repository is part of a repository, `False`
        otherwise.
    z.gitz
git branch)Úcwdr>   r:   r   )	ÚosÚpathÚexistsÚjoinrL   ÚrunÚsplitÚPIPEÚ
returncode)rR   Úfolder_existsÚ
git_branchs      r,   Úis_git_repor_   r   sd   € õ ”G—N’N¥2¤7§<¢<°¸Ñ#?Ô#?Ñ@Ô@€MÝ” × 2Ò 2Ñ 4Ô 4¸&ÍÌÕakÔapÐqÑqÔq€JØÐ7˜ZÔ2°aÒ7Ð7r.   Ú
remote_urlc                 ó¾   — t          | ¦  «        sdS t          d| ¦  «        j        }t          j        dd|¦  «        }d„ |                     ¦   «         D ¦   «         }||v S )am  
    Check if the folder is a local clone of the remote_url

    Args:
        folder (`str` or `Path`):
            The folder in which to run the command.
        remote_url (`str`):
            The url of a git repository.

    Returns:
        `bool`: `True` if the repository is a local clone of the remote
        repository specified, `False` otherwise.
    Fzgit remote -vúhttps://.*@úhttps://c                 ó:   — g | ]}t          j        d d|¦  «        ‘ŒS )rb   rc   )ÚreÚsub)Ú.0Úremotes     r,   ú
<listcomp>z"is_local_clone.<locals>.<listcomp>˜   s&   € ÐXÐXÐX¸f�rŒv�n j°&Ñ9Ô9ÐXÐXÐXr.   )r_   r   r>   re   rf   rZ   )rR   r`   Úremotess      r,   Úis_local_clonerk   ƒ   sf   € õ �vÑÔð Øˆuå˜_¨fÑ5Ô5Ô<€Gõ ”˜¨
°JÑ?Ô?€JØXÐXÈÏÊÉÌÐXÑXÔX€GØ˜Ð Ð r.   Úfilenamec                 óD  — t          | ¦  «        j        }t          | ¦  «        j        } 	 t          d                     ¦   «         | gz   |¦  «        }|j                             ¦   «         }n@# t          j        $ r.}t          |¦  «        sY d}~dS t          |j        ¦  «        ‚d}~ww xY wt          |¦  «        dk    rdS ddddœ}|                     d¦  «        D ]&}|                     ¦   «         D ]}||v r	d|v rd||<   ŒŒ't          |                     ¦   «         ¦  «        S )	zù
    Check if the file passed is tracked with git-lfs.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is tracked with git-lfs, `False`
        otherwise.
    zgit check-attr -aNFr   )ÚdiffÚmergeÚfilterú
ÚlfsT)r   ÚparentÚnamer   rZ   r>   ÚstriprL   ÚCalledProcessErrorr_   ÚOSErrorr:   ÚlenÚkeysÚallÚvalues)rl   rR   ÚpÚ
attributesÚexcÚfound_lfs_tagÚ	attributeÚtags           r,   Úis_tracked_with_lfsr‚   œ   sJ  € õ �(‰^Œ^Ô"€FÝ�H‰~Œ~Ô"€Hð&ÝÐ.×4Ò4Ñ6Ô6¸(¸ÑCÀVÑLÔLˆØ”X—^’^Ñ%Ô%ˆ
ˆ
øÝÔ(ð &ð &ð &Ý˜6Ñ"Ô"ð 	&Ø�5�5�5�5�5å˜#œ*Ñ%Ô%Ð%øøøøð	&øøøõ ˆ:�„˜!ÒÐØˆuà"¨U¸eÐDÐD€Mà×%Ò% dÑ+Ô+ð *ð *ˆ	Ø ×%Ò%Ñ'Ô'ð 	*ð 	*ˆCØ�iÐÐ E¨YÐ$6Ð$6Ø%)�˜cÑ"øð	*õ ˆ}×#Ò#Ñ%Ô%Ñ&Ô&Ð&s   ª?A* Á*B'Á9B"ÂB"Â"B'c                 ó*  — t          | ¦  «        j        }t          | ¦  «        j        } 	 t          d                     ¦   «         | gz   |d¬¦  «        }t          |j        ¦  «         }n+# t          j        $ r}t          |j
        ¦  «        ‚d}~ww xY w|S )a  
    Check if file is git-ignored. Supports nested .gitignore files.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is ignored by `git`, `False`
        otherwise.
    zgit check-ignoreF©ÚcheckN)r   rs   rt   r   rZ   rO   r\   rL   rv   rw   r:   )rl   rR   r|   Ú
is_ignoredr~   s        r,   Úis_git_ignoredr‡   Á   sœ   € õ �(‰^Œ^Ô"€FÝ�H‰~Œ~Ô"€Hð"ÝÐ-×3Ò3Ñ5Ô5¸¸
ÑBÀFÐRWÐXÑXÔXˆå˜aœlÑ+Ô+Ð+ˆ
ˆ
øÝÔ(ð "ð "ð "Ý�c”jÑ!Ô!Ð!øøøøð"øøøð Ðs   ª=A( Á(BÁ7BÂBc           	      óL  — 	 t          | d¦  «        5 }|                     d¦  «        }ddd¦  «         n# 1 swxY w Y   t          h d£t          t	          dd¦  «        ¦  «        dhz
  z  ¦  «        }t          |                     d|¦  «        ¦  «        S # t          $ r Y dS w xY w)	zØ
    Check if file is a binary file.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is a binary file, `False` otherwise.
    Úrbi    N>   é   é   é	   é
   é   é   é   é    é   é   T)Úopenr;   Ú	bytearrayÚsetÚrangerO   Ú	translateÚUnicodeDecodeError)rl   ÚfÚcontentÚ
text_charss       r,   Úis_binary_filer�   Ú   sð   € ð	Ý�(˜DÑ!Ô!ð 	- QØ—f’f˜^Ñ,Ô,ˆGð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-õ
 Ð8Ð8Ð8½3½uÀTÈ5Ñ?QÔ?QÑ;RÔ;RÐVZÐU[Ñ;[Ñ[Ñ\Ô\ˆ
Ý�G×%Ò% d¨JÑ7Ô7Ñ8Ô8Ð8øÝð ð ð Øˆtˆtðøøøs-   ‚B ’4¨B ´8¸B »8¼AB Â
B#Â"B#ú.Úpatternc                 óV  — 	 t          d                     ¦   «         | gz   |¦  «        }t          |j                             ¦   «         ¦  «        r-|j                             ¦   «                              d¦  «        }ng }n+# t
          j        $ r}t          |j        ¦  «        ‚d}~ww xY w|S )aQ  
    Returns a list of filenames that are to be staged.

    Args:
        pattern (`str` or `Path`):
            The pattern of filenames to check. Put `.` to get all files.
        folder (`str` or `Path`):
            The folder in which to run the command.

    Returns:
        `List[str]`: List of files that are to be staged.
    z#git ls-files --exclude-standard -morq   N)	r   rZ   rx   r>   ru   rL   rv   ÚEnvironmentErrorr:   )rŸ   rR   r|   Úfilesr~   s        r,   Úfiles_to_be_stagedr£   ñ   s§   € ð+ÝÐ@×FÒFÑHÔHÈGÈ9ÑTÐV\Ñ]Ô]ˆÝˆqŒx�~Š~ÑÔÑ Ô ð 	Ø”H—N’NÑ$Ô$×*Ò*¨4Ñ0Ô0ˆEˆEàˆEøøÝÔ(ð +ð +ð +Ý˜sœzÑ*Ô*Ð*øøøøð+øøøð €Ls   ‚A;A> Á>B&ÂB!Â!B&c                 ó’   — 	 t          d| ¦  «         dS # t          j        $ r#}d|j        v rt	          d¦  «        ‚Y d}~dS d}~ww xY w)a  
    Check if the current checked-out branch is tracked upstream.

    Args:
        folder (`str` or `Path`):
            The folder in which to run the command.

    Returns:
        `bool`: `True` if the current checked-out branch is tracked upstream,
        `False` otherwise.
    z4git rev-parse --symbolic-full-name --abbrev-ref @{u}TÚHEADzNo branch checked outNF)r   rL   rv   r:   rw   )rR   r~   s     r,   Úis_tracked_upstreamr¦   
  sh   € ðÝÐMÈvÑVÔVÐVØˆtøÝÔ(ð ð ð Ø�S”ZÐÐÝÐ1Ñ2Ô2Ð2àˆuˆuˆuˆuˆuøøøøð	øøøs   ‚ ”A£AÁAÚupstreamc                 óØ   — 	 t          d|pd› �| ¦  «        }t          |j                             d¦  «        ¦  «        dz
  S # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)a³  
        Check the number of commits that would be pushed upstream

        Args:
            folder (`str` or `Path`):
                The folder in which to run the command.
            upstream (`str`, *optional*):
    The name of the upstream repository with which the comparison should be
    made.

        Returns:
            `int`: Number of commits that would be pushed upstream were a `git
            push` to proceed.
    zgit cherry -v r$   rq   r   N)r   rx   r>   rZ   rL   rv   r¡   r:   )rR   r§   r1   r~   s       r,   Úcommits_to_pushr©      sx   € ð+ÝÐ A°°¸RÐ AÐ AÀ6ÑJÔJˆÝ�6”=×&Ò& tÑ,Ô,Ñ-Ô-°Ñ1Ð1øÝÔ(ð +ð +ð +Ý˜sœzÑ*Ô*Ð*øøøøð+øøøs   ‚>A ÁA)ÁA$Á$A)c                   ó$   — e Zd ZU eed<   eed<   dS )ÚPbarTÚbarÚ
past_bytesN)rG   rH   rI   r   Ú__annotations__rP   rQ   r.   r,   r«   r«   6  s"   € € € € € € à	€I€I�IØ€O€O�O€O€Or.   r«   c               #   ó\  K  — t                                ¦   «         t          j        k    r	 dV — n# t          $ r Y nw xY wdS dt
          j        fd„} t          j         	                    dd¦  «        }t          ¦   «         5 }t          j                             |d¦  «        t          j        d<   t                                dt          j        d         › �¦  «         t          j        ¦   «         }t          j        | |fd¬	¦  «        }|                     ¦   «          	 dV — |                     ¦   «          |                     ¦   «          |t          j        d<   n<# |                     ¦   «          |                     ¦   «          |t          j        d<   w xY w	 ddd¦  «         dS # 1 swxY w Y   dS )
zv
    This is a context manager that will log the Git LFS progress of cleaning,
    smudging, pulling and pushing.
    NÚstopping_eventc           
      óª  ‡ ‡‡— i Šˆfd„Šdt           t                   fˆˆ fd„}t          j                             t          j        d         ¦  «        sc‰                      ¦   «         r ‰¦   «          dS t          j        d¦  «         t          j                             t          j        d         ¦  «        ¯c |t          j        d         ¦  «        D �] }	 | 	                    ¦   «         \  }}}}n%# t          $ r}t          d|› �¦  «        |‚d}~ww xY w|                     ¦   «         › d|› �}| 	                    d	¦  «        \  }	}
t          |	¦  «        }t          |
¦  «        }‰                     ||f¦  «        }|€,t          |||d
ddd¬¦  «        t          |	¦  «        dœ‰||f<   Œ×|d                              ||d         z
  ¦  «         ||d<   �ŒdS )zl
        To be launched as a separate thread with an event meaning it should stop
        the tail.
        c                  óü   •— ‰                      ¦   «         D ]e} | d                              | d         j        | d         z
  ¦  «         | d                              ¦   «          | d                              ¦   «          Œfd S )Nr¬   r­   )r{   ÚupdateÚtotalÚrefreshÚclose)ÚpbarÚpbarss    €r,   Úclose_pbarsz?_lfs_log_progress.<locals>.output_progress.<locals>.close_pbarsR  s|   ø€ ØŸš™œð $ð $�Ø�U”×"Ò" 4¨¤;Ô#4°t¸LÔ7IÑ#IÑJÔJÐJØ�U”×#Ò#Ñ%Ô%Ð%Ø�U”×!Ò!Ñ#Ô#Ð#Ð#ð$ð $r.   r/   c              3   ó†  •K  — t          | d¦  «        5 }d}	 ‰                     ¦   «         r ‰¦   «          nq|                     ¦   «         }|�Ft          |                     ¦   «         ¦  «        dk    s!||z  }|                     d¦  «        r|V — d}nt          j        d¦  «         Œ�	 ddd¦  «         dS # 1 swxY w Y   dS )z¾
            Creates a generator to be iterated through, which will return each
            line one by one. Will stop tailing the file if the stopping_event is
            set.
            Úrr$   TNr   rq   r   )r”   Úis_setÚreadlinerx   ru   ÚendswithÚtimeÚsleep)rl   ÚfileÚcurrent_lineÚline_bitr¹   r°   s       €€r,   Ú	tail_filez=_lfs_log_progress.<locals>.output_progress.<locals>.tail_fileX  s  øè è € õ �h Ñ$Ô$ð &¨Ø!�ð&Ø%×,Ò,Ñ.Ô.ð Ø#˜™œ˜Øà#Ÿ}š}™œ�HØÐ+µC¸¿ºÑ8HÔ8HÑ4IÔ4IÈQÒ4NÐ4NØ$¨Ñ0˜Ø'×0Ò0°Ñ6Ô6ð .Ø".Ð.Ð.Ð.Ø+-˜Løåœ
 1™œ˜ð&ð ð&ð &ð &ñ &ô &ð &ð &ð &ð &ð &ð &ð &øøøð &ð &ð &ð &ð &ð &s   ”BB6Â6B:Â=B:ÚGIT_LFS_PROGRESSNé   z!Cannot unpack LFS progress line:
z file ú/ÚBTi   zhuggingface_hub.lfs_upload)ÚdescÚinitialr´   ÚunitÚ
unit_scaleÚunit_divisorrt   )r¬   r­   r¬   r­   )r   rK   rU   rV   rW   Úenvironr¼   r¿   rÀ   rZ   Ú
ValueErrorÚ
capitalizerP   Úgetr   r³   )r°   rÄ   ÚlineÚstateÚfile_progressÚbyte_progressrl   ÚerrorÚdescriptionÚcurrent_bytesÚtotal_bytesÚcurrent_bytes_intÚtotal_bytes_intr·   r¹   r¸   s   `             @@r,   Úoutput_progressz*_lfs_log_progress.<locals>.output_progressJ  s<  øøø€ ð /1ˆð	$ð 	$ð 	$ð 	$ð 	$ð	&¥8­C¤=ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&õ0 ”'—.’.¥¤Ð,>Ô!?Ñ@Ô@ð 	Ø×$Ò$Ñ&Ô&ð Ø�‘”�Ø�åŒJ�q‰MŒMˆMõ ”'—.’.¥¤Ð,>Ô!?Ñ@Ô@ð 	ð �I�bœjÐ);Ô<Ñ=Ô=ð 	7ñ 	7ˆDðYØ@DÇ
Â
ÁÄÑ=��} m°X°XøÝð Yð Yð Yå Ð!LÀdÐ!LÐ!LÑMÔMÐSXÐXøøøøðYøøøð #×-Ò-Ñ/Ô/ÐAÐA°xÐAÐAˆKà)6×)<Ò)<¸SÑ)AÔ)AÑ&ˆM˜;Ý # MÑ 2Ô 2ÐÝ! +Ñ.Ô.ˆOà—9’9˜e XÐ.Ñ/Ô/ˆDØˆ|õ  Ø(Ø 1Ø-Ø Ø#'Ø%)Ø9ðñ ô õ #& mÑ"4Ô"4ð,ð ,��u˜hÐ'Ñ(Ð(ð �U”×"Ò"Ð#4°t¸LÔ7IÑ#IÑJÔJÐJØ%6��\Ñ"Ñ"ð=	7ð 	7s   ÃC/Ã/
DÃ9DÄDrÅ   r$   Úlfs_progresszFollowing progress in T)ÚtargetÚargsÚdaemon)ÚloggerÚgetEffectiveLevelr   ÚERRORÚ	ExceptionÚ	threadingÚEventrU   rÎ   rÑ   r   rV   rX   ÚdebugÚThreadÚstartr–   )rÜ   Úcurrent_lfs_progress_valueÚtmpdirÚ
exit_eventÚxs        r,   Ú_lfs_log_progressrî   <  sþ  è è € õ ×ÒÑ!Ô!¥W¤]Ò2Ð2ð	ØˆEˆEˆEˆEøÝð 	ð 	ð 	ØˆDð	øøøàˆðK7­	¬ð K7ð K7ð K7ð K7õZ "$¤§¢Ð0BÀBÑ!GÔ!GÐå	Ñ	!Ô	!ð H VÝ)+¬¯ª°f¸nÑ)MÔ)M�Œ
Ð%Ñ&Ý�ŠÐN­b¬jÐ9KÔ.LÐNÐNÑOÔOÐOå”_Ñ&Ô&ˆ
ÝÔ O¸:¸-ÐPTÐUÑUÔUˆØ	�Š‰	Œ	ˆ	ð	HØˆEˆEˆEà�NŠNÑÔÐØ�FŠF‰HŒHˆHà-G�BŒJÐ)Ñ*Ð*øð �NŠNÑÔÐØ�FŠF‰HŒHˆHà-G�BŒJÐ)Ñ*ÐGÐGÐGÐGÐ*ðHð Hð Hñ Hô Hð Hð Hð Hð Hð Hð Hð Høøøð Hð Hð Hð Hð Hð Hs7   «0 °
=¼=Â BF!ÄEÄ8F!Å9FÆF!Æ!F%Æ(F%c                   óZ  — e Zd ZU dZee         ed<   e edd¬¦  «        	 	 	 	 	 	 	 	 dHd	e	e
ef         d
ee
         dee
         de	ee
f         dee
         dee
         dee
         dedee         fd„¦   «         ¦   «         Zede
fd„¦   «         Zd„ ZedIde
de	ee
df         fd„¦   «         ZdJdee
         dee
         fd„Zd„ Zde
fd„Zde
fd„Zde
fd„Zdee
         fd„ZdKde	e
ee
         f         defd „Zde	e
ee
         f         fd!„Zd"„ ZdLd$e
dee
         fd%„ZdLd$e
dee
         fd&„ZdKd'„ZdMd(ed)efd*„Z dNd$e
d+efd,„Z!dOd.e
fd/„Z"	 	 	 dPd0ee
         d1ed2ede	e
e#e
ef         f         fd3„Z$dKde
d4efd5„Z%dId6e
d7ee
         defd8„Z&dId6e
d7ee
         defd9„Z'dJd6e
d:ee
         d7ee
         fd;„Z(defd<„Z)	 	 	 	 dQd.e
d1ed=ed2ede	de
e#e
ef         f         f
d>„Z*e+	 	 	 	 dRd.e
d?ee
         d@ed1ed2ef
dA„¦   «         Z,dee-         fdB„Z.dCe-ddfdD„Z/edE„ ¦   «         Z0edF„ ¦   «         Z1dG„ Z2dS )SÚ
RepositoryaR  
    Helper class to wrap the git and git-lfs commands.

    The aim is to facilitate interacting with huggingface.co hosted model or
    dataset repos, though not a lot here (if any) is actually specific to
    huggingface.co.

    <Tip warning={true}>

    [`Repository`] is deprecated in favor of the http-based alternatives implemented in
    [`HfApi`]. Given its large adoption in legacy code, the complete removal of
    [`Repository`] will only happen in release `v1.0`. For more details, please read
    https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.

    </Tip>
    Úcommand_queuez1.0z÷Please prefer the http-based alternatives instead. Given its large adoption in legacy code, the complete removal is only planned on next major release.
For more details, please read https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.)ÚversionÚmessageNTFÚ	local_dirÚ
clone_fromÚ	repo_typeÚtokenÚgit_userÚ	git_emailÚrevisionÚskip_lfs_filesÚclientc
                 ó$  — t          |t          ¦  «        rt          |¦  «        }t          j        |d¬¦  «         t          j                             t          j        ¦   «         |¦  «        | _        || _	        g | _
        || _        |	�|	nt          ¦   «         | _        |                      ¦   «          t          |t          ¦  «        r|| _        n|du rd| _        nt!          ¦   «         | _        |�|                      |¬¦  «         n>t%          | j        ¦  «        rt&                               d¦  «         nt+          d¦  «        ‚| j        �Q|�|€M| j                             | j        ¦  «        }
|€|
                     d¦  «        }|€|
                     d	¦  «        }|€|�|                      ||¦  «         |                      ¦   «          |                      ¦   «          |�|                      |d¬
¦  «         t9          j        | j        ¦  «         dS )aÈ	  
        Instantiate a local clone of a git repo.

        If `clone_from` is set, the repo will be cloned from an existing remote repository.
        If the remote repo does not exist, a `EnvironmentError` exception will be thrown.
        Please create the remote repo first using [`create_repo`].

        `Repository` uses the local git credentials by default. If explicitly set, the `token`
        or the `git_user`/`git_email` pair will be used instead.

        Args:
            local_dir (`str` or `Path`):
                path (e.g. `'my_trained_model/'`) to the local directory, where
                the `Repository` will be initialized.
            clone_from (`str`, *optional*):
                Either a repository url or `repo_id`.
                Example:
                - `"https://huggingface.co/philschmid/playground-tests"`
                - `"philschmid/playground-tests"`
            repo_type (`str`, *optional*):
                To set when cloning a repo from a repo_id. Default is model.
            token (`bool` or `str`, *optional*):
                A valid authentication token (see https://huggingface.co/settings/token).
                If `None` or `True` and machine is logged in (through `hf auth login`
                or [`~huggingface_hub.login`]), token will be retrieved from the cache.
                If `False`, token is not sent in the request header.
            git_user (`str`, *optional*):
                will override the `git config user.name` for committing and
                pushing files to the hub.
            git_email (`str`, *optional*):
                will override the `git config user.email` for committing and
                pushing files to the hub.
            revision (`str`, *optional*):
                Revision to checkout after initializing the repository. If the
                revision doesn't exist, a branch will be created with that
                revision name from the default branch's current HEAD.
            skip_lfs_files (`bool`, *optional*, defaults to `False`):
                whether to skip git-LFS files or not.
            client (`HfApi`, *optional*):
                Instance of [`HfApi`] to use when calling the HF Hub API. A new
                instance will be created if this is left to `None`.

        Raises:
            [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
                If the remote repository set in `clone_from` does not exist.
        T)Úexist_okNF)Úrepo_urlz [Repository] is a valid git repozNIf not specifying `clone_from`, you need to pass Repository a valid git clone.ÚemailÚfullname©Úcreate_branch_ok)Ú
isinstancer   rK   rU   ÚmakedirsrV   rX   Úgetcwdrô   Ú
_repo_typerñ   rû   r   rü   Úcheck_git_versionsÚhuggingface_tokenr   rõ   r_   rá   rç   rÏ   ÚwhoamirÑ   Úgit_config_username_and_emailÚlfs_enable_largefilesÚgit_credential_helper_storeÚgit_checkoutÚatexitÚregisterÚwait_for_commands)r+   rô   rõ   rö   r÷   rø   rù   rú   rû   rü   Úusers              r,   r-   zRepository.__init__¾  sý  € õF �i¥Ñ&Ô&ð 	'Ý˜I™œˆIÝ
Œ�I¨Ð-Ñ-Ô-Ð-ÝœŸš¥b¤i¡k¤k°9Ñ=Ô=ˆŒØ#ˆŒØˆÔØ,ˆÔØ &Ð 2�f�f½¹¼ˆŒà×ÒÑ!Ô!Ð!å�e�SÑ!Ô!ð 	1Ø49ˆDÔ"Ð"Ø�eˆ^ˆ^Ø%)ˆDÔ"Ð"õ &/¡[¤[ˆDÔ"àÐ!Ø�OŠO ZˆOÑ0Ô0Ð0Ð0å˜4œ>Ñ*Ô*ð sÝ—’Ð?Ñ@Ô@Ð@Ð@å Ð!qÑrÔrÐràÔ!Ð-°9Ð3DÈÐHXØ”;×%Ò% dÔ&<Ñ=Ô=ˆDàÐ Ø ŸHšH WÑ-Ô-�	àÐØŸ8š8 JÑ/Ô/�àÐ 9Ð#8Ø×.Ò.¨x¸ÑCÔCÐCà×"Ò"Ñ$Ô$Ð$Ø×(Ò(Ñ*Ô*Ð*àÐØ×Ò˜h¸ÐÑ>Ô>Ð>õ 	Œ˜Ô.Ñ/Ô/Ð/Ð/Ð/r.   r/   c                 ó¸   — 	 t          d| j        ¦  «        j                             ¦   «         }n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w|S )zz
        Returns the current checked out branch.

        Returns:
            `str`: Current checked out branch.
        zgit rev-parse --abbrev-ref HEADN©r   rô   r>   ru   rL   rv   r¡   r:   )r+   r1   r~   s      r,   Úcurrent_branchzRepository.current_branch3  sc   € ð	/Ý#Ð$EÀtÄ~ÑVÔVÔ]×cÒcÑeÔeˆFˆFøÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøð ˆó   ‚,/ ¯A¾AÁAc                 ór  — 	 t          d| j        ¦  «        j                             ¦   «         }n# t          $ r t          d¦  «        ‚w xY w	 t          d| j        ¦  «        j                             ¦   «         }n# t          $ r t          d¦  «        ‚w xY wt                               |dz   |z   ¦  «         dS )zì
        Checks that `git` and `git-lfs` can be run.

        Raises:
            [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
                If `git` or `git-lfs` are not installed.
        zgit --versionz9Looks like you do not have git installed, please install.zgit-lfs --versionz«Looks like you do not have git-lfs installed, please install. You can install from https://git-lfs.github.com/. Then run `git lfs install` (you only have to do this once).rq   N)r   rô   r>   ru   ÚFileNotFoundErrorr¡   rá   Úinfo)r+   Úgit_versionÚlfs_versions      r,   r  zRepository.check_git_versionsB  s×   € ð	`Ý(¨¸$¼.ÑIÔIÔP×VÒVÑXÔXˆKˆKøÝ ð 	`ð 	`ð 	`Ý"Ð#^Ñ_Ô_Ð_ð	`øøøð	Ý(Ð)<¸d¼nÑMÔMÔT×ZÒZÑ\Ô\ˆKˆKøÝ ð 	ð 	ð 	Ý"ðOñô ð ð	øøøõ 	�Š�K $Ñ&¨Ñ4Ñ5Ô5Ð5Ð5Ð5s   ‚,/ ¯A	Á,A: Á:Brÿ   c                 ó$  — t          |t          ¦  «        r|n|du rdn| j        }|�$|                     d¦  «        rt	          d¦  «        ‚| j        j        }||v s*d|vr»t          |                     d¦  «        ¦  «        dk    r•t          ||¬¦  «        \  }}}|�|› d|› �n|}|�|| _
        |dz   }| j
        t          j        v r|t          j        | j
                 z  }|�3t          |¦  «        j        }|                     |› d	�|› d
|› d�¦  «        }||z  }t!          j        dd|¦  «        }		 t%          d| j        ¦  «         t          t)          j        | j        ¦  «        ¦  «        dk    rªt,                               d|	› d�¦  «         t1          ¦   «         5  t(          j                             ¦   «         }
| j        r|
                     ddi¦  «         t%          | j        rdnd› d|› d�| j        |
¬¦  «         ddd¦  «         n# 1 swxY w Y   dS dS t;          | j        ¦  «        s t=          d| j        › d| j        › d�¦  «        ‚t?          | j        |¦  «        r't,                               | j        › d|	› d�¦  «         dS t%          d| j        d¬¦  «        }d |	› d!|	› d"�}|j         dk    r#t!          j        d#d$|j!        ¦  «        }|d%|› �z  }t=          |¦  «        ‚# tD          j#        $ r}t=          |j$        ¦  «        ‚d}~ww xY w)&a›  
        Clone from a remote. If the folder already exists, will try to clone the
        repository within it.

        If this folder is a git repository with linked history, will try to
        update the repository.

        Args:
            repo_url (`str`):
                The URL from which to clone the repository
            token (`Union[str, bool]`, *optional*):
                Whether to use the authentication token. It can be:
                 - a string which is the token itself
                 - `False`, which would not use the authentication token
                 - `True`, which would fetch the authentication token from the
                   local folder and use it (you should be logged in for this to
                   work).
                - `None`, which would retrieve the value of
                  `self.huggingface_token`.

        <Tip>

        Raises the following error:

            - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
              if an organization token (starts with "api_org") is passed. Use must use
              your own personal access token (see https://hf.co/settings/tokens).

            - [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
              if you are trying to clone the repository in a non-empty folder, or if the
              `git` operations raise errors.

        </Tip>
        FNÚapi_orgzgYou must use your personal access token, not an Organization token (see https://hf.co/settings/tokens).ÚhttprÇ   rÆ   )Úhub_urlz://z://user:ú@z(https?)://.*@z\1://zgit lfs installr   zCloning z into local empty directory.ÚGIT_LFS_SKIP_SMUDGEÚ1z	git clonezgit lfs cloneú z .)ÚenvzPTried to clone a repository in a non-empty folder that isn't a git repository ('z7'). If you really want to do this, do it manually:
 cd z‹ && git init && git remote add origin && git pull origin main
 or clone repo to a new folder and move your existing files there afterwards.z is already a clone of z?. Make sure you pull the latest changes with `repo.git_pull()`.zgit remote get-url originr„   zTried to clone zn in an unrelated git repository.
If you believe this is an error, please add a remote with the following URL: rž   rb   rc   z'
Local path has its origin defined as: )%r  rK   r	  Ú
startswithrÏ   rü   Úendpointrx   rZ   r   r  r   ÚREPO_TYPES_URL_PREFIXESr   ÚschemeÚreplacere   rf   r   rô   rU   Úlistdirrá   Úwarningrî   rÎ   Úcopyrû   r³   r_   r¡   rk   r\   r>   rL   rv   r:   )r+   rÿ   r÷   r  rö   Ú	namespaceÚ	repo_nameÚrepo_idr(  Úclean_repo_urlr$  ÚoutputÚ	error_msgÚclean_local_remote_urlr~   s                  r,   rõ   zRepository.clone_fromY  s)  € õL ˜%¥Ñ%Ô%ðˆEˆEð ˜E�>�>ð �àÔ+ð 	ð Ð ×!1Ò!1°)Ñ!<Ô!<ÐÝð8ñô ð ð
 ”+Ô&ˆØ�hÐÐ 6°Ð#9Ð#9½cÀ(Ç.Â.ÐQTÑBUÔBUÑ>VÔ>VÐZ[Ò>[Ð>[Ý.IÈ(Ð\cÐ.dÑ.dÔ.dÑ+ˆI�y )Ø4=Ð4I˜Ð0Ð0 YÐ0Ð0Ð0ÈyˆGàÐ$Ø"+�”à ‘}ˆHàŒ¥)Ô"CÐCÐCØ�IÔ=¸d¼oÔNÑN�àÐ å! (Ñ+Ô+Ô2�Ø#×+Ò+¨v¨N¨N¨N¸vÐ<WÐ<WÈuÐ<WÐ<WÐ<WÑXÔX�à˜ÑˆHõ œÐ 1°8¸XÑFÔFˆð5	/ÝÐ,¨d¬nÑ=Ô=Ð=õ •2”:˜dœnÑ-Ô-Ñ.Ô.°!Ò3Ð3Ý—’ÐV¨.ÐVÐVÐVÑWÔWÐWå&Ñ(Ô(ð ð Ýœ*Ÿ/š/Ñ+Ô+�CàÔ*ð AØŸ
š
Ð$9¸3Ð#?Ñ@Ô@Ð@å"ð +/Ô*=ÐR˜;˜;À?ÐaÐaÐU]ÐaÐaÐaØœØðñ ô ð ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð ð ð ð õ  # 4¤>Ñ2Ô2ð Ý*ð'Ø/3¬~ð'ð 'à:>¼.ð'ð 'ð 'ñô ð õ " $¤.°(Ñ;Ô;ð 6Ý—N’NØœ>ð .ð .À.ð .ð .ð .ñô ð ð ð õ ,Ð,GÈÌÐ_dÐeÑeÔe�FðO¨.ð Oð Oà=KðOð Oð Oð ð
 Ô(¨AÒ-Ð-Ý13´¸È
ÐTZÔTaÑ1bÔ1bÐ.Ø!Ð%hÐPfÐ%hÐ%hÑh˜	Ý*¨9Ñ5Ô5Ð5øåÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøsL   Ä1A+K' ÆA#HÇ?K' ÈHÈK' ÈHÈK' ÈA.K' Ê
AK' Ë'LË6L
Ì
Lc                 ó  — 	 |�+t          d                     ¦   «         |gz   | j        ¦  «         |�,t          d|› �                     ¦   «         | j        ¦  «         dS dS # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)a  
        Sets git username and email (only in the current repo).

        Args:
            git_user (`str`, *optional*):
                The username to register through `git`.
            git_email (`str`, *optional*):
                The email to register through `git`.
        Nzgit config user.namezgit config user.email )r   rZ   rô   rL   rv   r¡   r:   )r+   rø   rù   r~   s       r,   r  z(Repository.git_config_username_and_emailÙ  s    € ð	/ØÐ#ÝÐ5×;Ò;Ñ=Ô=ÀÀ
ÑJÈDÌNÑ[Ô[Ð[àÐ$ÝÐC¸	ÐCÐC×IÒIÑKÔKÈTÌ^Ñ\Ô\Ð\Ð\Ð\ð %Ð$øåÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   ‚AA ÁBÁ.BÂBc                 óˆ   — 	 t          d| j        ¦  «         dS # t          j        $ r}t	          |j        ¦  «        ‚d}~ww xY w)z;
        Sets the git credential helper to `store`
        z"git config credential.helper storeN)r   rô   rL   rv   r¡   r:   )r+   r~   s     r,   r  z&Repository.git_credential_helper_storeì  sR   € ð	/ÝÐ?ÀÄÑPÔPÐPÐPÐPøÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   ‚ ™A¨<¼Ac                 ó¶   — 	 t          d| j        ¦  «        }|j                             ¦   «         S # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)zy
        Get commit sha on top of HEAD.

        Returns:
            `str`: The current checked out commit SHA.
        zgit rev-parse HEADNr  )r+   r|   r~   s      r,   Úgit_head_hashzRepository.git_head_hashõ  s]   € ð	/ÝÐ3°T´^ÑDÔDˆAØ”8—>’>Ñ#Ô#Ð#øÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   ‚-0 °A¿AÁAc                 óâ   — 	 t          d| j        ¦  «        }|j                             ¦   «         }t	          j        dd|¦  «        S # t          j        $ r}t          |j	        ¦  «        ‚d}~ww xY w)zp
        Get URL to origin remote.

        Returns:
            `str`: The URL of the `origin` remote.
        z"git config --get remote.origin.urlrb   rc   N)
r   rô   r>   ru   re   rf   rL   rv   r¡   r:   )r+   r|   Úurlr~   s       r,   Úgit_remote_urlzRepository.git_remote_url  sp   € ð	/ÝÐCÀTÄ^ÑTÔTˆAØ”(—.’.Ñ"Ô"ˆCå”6˜.¨*°cÑ:Ô:Ð:øÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   ‚AA ÁA.ÁA)Á)A.c                 óž   — |                       ¦   «         }|                      ¦   «         }|                     d¦  «        r
|dd…         }|› d|› �S )zæ
        Get URL to last commit on HEAD. We assume it's been pushed, and the url
        scheme is the same one as for GitHub or HuggingFace.

        Returns:
            `str`: The URL to the current checked-out commit.
        rÇ   Nr@   z/commit/)r7  r:  r¾   )r+   Úshar9  s      r,   Úgit_head_commit_urlzRepository.git_head_commit_url  s[   € ð × Ò Ñ"Ô"ˆØ×!Ò!Ñ#Ô#ˆØ�<Š<˜ÑÔð 	Ø�c�r�c”(ˆCØÐ$Ð$˜sÐ$Ð$Ð$r.   c                 óP  — 	 t          d| j        ¦  «        j                             ¦   «         }n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY wt          |¦  «        dk    rg S d„ | 	                    d¦  «        D ¦   «         }d„ |D ¦   «         }d„ |D ¦   «         }|S )zê
        Returns a list of the files that are deleted in the working directory or
        index.

        Returns:
            `List[str]`: A list of files that have been deleted in the working
            directory or index.
        zgit status -sNr   c                 ó6   — g | ]}|                      ¦   «         ‘ŒS rQ   )ru   ©rg   r5   s     r,   ri   z1Repository.list_deleted_files.<locals>.<listcomp>8  s    € Ð"WÐ"WÐ"W°f 6§<¢<¡>¤>Ð"WÐ"WÐ"Wr.   rq   c                 óJ   — g | ] }d |                      ¦   «         d         v ¯|‘Œ!S )ÚDr   )rZ   r@  s     r,   ri   z1Repository.list_deleted_files.<locals>.<listcomp>;  s6   € Ð!kÐ!kÐ!k¨VÐRUÐY_×YeÒYeÑYgÔYgÐhiÔYjÐRjÐRj &ÐRjÐRjÐRjr.   c                 óf   — g | ].}|                      ¦   «         d                               ¦   «         ‘Œ/S )r@   )rZ   ru   r@  s     r,   ri   z1Repository.list_deleted_files.<locals>.<listcomp>>  s1   € ÐYÐYÐY¸˜Ÿš™œ¨Ô+×1Ò1Ñ3Ô3ÐYÐYÐYr.   ©
r   rô   r>   ru   rL   rv   r¡   r:   rx   rZ   )r+   Ú
git_statusr~   Úmodified_files_statusesÚdeleted_files_statusesÚdeleted_filess         r,   Úlist_deleted_fileszRepository.list_deleted_files  sÎ   € ð	/Ý'¨¸¼ÑHÔHÔO×UÒUÑWÔWˆJˆJøÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøõ ˆz‰?Œ?˜aÒÐØˆIð #XÐ"WÀ
×@PÒ@PÐQUÑ@VÔ@VÐ"WÑ"WÔ"WÐð "lÐ!kÐ7NÐ!kÑ!kÔ!kÐð ZÐYÐBXÐYÑYÔYˆàÐr  Úpatternsrl   c                 óÖ   — t          |t          ¦  «        r|g}	 |D ]!}t          d|rdnd› d|› �| j        ¦  «         Œ"dS # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)a9  
        Tell git-lfs to track files according to a pattern.

        Setting the `filename` argument to `True` will treat the arguments as
        literal filenames, not as patterns. Any special glob characters in the
        filename will be escaped when writing to the `.gitattributes` file.

        Args:
            patterns (`Union[str, List[str]]`):
                The pattern, or list of patterns, to track with git-lfs.
            filename (`bool`, *optional*, defaults to `False`):
                Whether to use the patterns as literal filenames.
        zgit lfs track z
--filenamer$   r#  N)r  rK   r   rô   rL   rv   r¡   r:   )r+   rJ  rl   rŸ   r~   s        r,   Ú	lfs_trackzRepository.lfs_trackB  s§   € õ �h¥Ñ$Ô$ð 	"Ø �zˆHð	/Ø#ð ð �ÝØQ°XÐ%E \ \À2ÐQÐQÈÐQÐQØ”Nñô ð ð ðð øõ
 Ô,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   š$A  Á A(ÁA#Á#A(c                 óî   — t          |t          ¦  «        r|g}	 |D ]-}t          d                     ¦   «         |gz   | j        ¦  «         Œ.dS # t
          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)zÀ
        Tell git-lfs to untrack those files.

        Args:
            patterns (`Union[str, List[str]]`):
                The pattern, or list of patterns, to untrack with git-lfs.
        zgit lfs untrackN)	r  rK   r   rZ   rô   rL   rv   r¡   r:   )r+   rJ  rŸ   r~   s       r,   Úlfs_untrackzRepository.lfs_untrack[  sš   € õ �h¥Ñ$Ô$ð 	"Ø �zˆHð	/Ø#ð Vð V�ÝÐ0×6Ò6Ñ8Ô8¸G¸9ÑDÀdÄnÑUÔUÐUÐUðVð VøåÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   š0A ÁA4ÁA/Á/A4c                 óÐ   — 	 d}t          |› d�| j        ¦  «         t          |› dt          › �| j        ¦  «         dS # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)zI
        HF-specific. This enables upload support of files >5GB.
        z'git config lfs.customtransfer.multipartz.path hfz.args N)r   rô   r   rL   rv   r¡   r:   )r+   Ú
lfs_configr~   s      r,   r  z Repository.lfs_enable_largefilesk  sŽ   € ð	/ØBˆJÝ˜jÐ2Ð2Ð2°D´NÑCÔCÐCÝØÐCÐCÕ%AÐCÐCØ”ñô ð ð ð øõ Ô,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   ‚9= ½A%ÁA Á A%rž   rŸ   c                 ó<  — g }|                       ¦   «         }t          || j        ¬¦  «        D ]Ù}||v rŒt          j                             t          j        ¦   «         | j        |¦  «        }t          |¦  «        sŒt          |¦  «        s}t          j         	                    |¦  «        dz  }|dk    rt                               d¦  «         t          |¦  «        }|r*|                      |¦  «         |                     |¦  «         ŒÚ|                      |¦  «         |S )aH  
        Automatically track binary files with git-lfs.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to track files that are binary.

        Returns:
            `List[str]`: List of filenames that are now tracked due to being
            binary files
        ©rR   é   r�   z¨Parsing a large file to check if binary or not. Tracking large files using `repository.auto_track_large_files` is recommended so as to not load the full file in memory.)rI  r£   rô   rU   rV   rX   r  r‚   r‡   Úgetsizerá   r+  r�   rL  ÚappendrN  )r+   rŸ   Úfiles_to_be_tracked_with_lfsrH  rl   Úpath_to_fileÚ
size_in_mbÚ	is_binarys           r,   Úauto_track_binary_filesz"Repository.auto_track_binary_filesy  s#  € ð (*Ð$à×/Ò/Ñ1Ô1ˆå*¨7¸4¼>ÐJÑJÔJð 	Bð 	BˆHØ˜=Ð(Ð(Øåœ7Ÿ<š<­¬	©¬°T´^ÀXÑNÔNˆLå'¨Ñ5Ô5ð B½ÈÑ9UÔ9Uð BÝœWŸ_š_¨\Ñ:Ô:¸kÑJ�
à Ò#Ð#Ý—N’NðRñô ð õ +¨<Ñ8Ô8�	àð BØ—N’N 8Ñ,Ô,Ð,Ø0×7Ò7¸ÑAÔAÐAøð 	×Ò˜Ñ'Ô'Ð'à+Ð+r.   c                 óæ  — g }|                       ¦   «         }t          || j        ¬¦  «        D ]®}||v rŒt          j                             t          j        ¦   «         | j        |¦  «        }t          j                             |¦  «        dz  }|dk    rHt          |¦  «        s9t          |¦  «        s*|  
                    |¦  «         |                     |¦  «         Œ¯|                      |¦  «         |S )ap  
        Automatically track large files (files that weigh more than 10MBs) with
        git-lfs.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to track files that are above 10MBs.

        Returns:
            `List[str]`: List of filenames that are now tracked due to their
            size.
        rR  rS  r�   )rI  r£   rô   rU   rV   rX   r  rT  r‚   r‡   rL  rU  rN  )r+   rŸ   rV  rH  rl   rW  rX  s          r,   Úauto_track_large_filesz!Repository.auto_track_large_files¤  sé   € ð (*Ð$à×/Ò/Ñ1Ô1ˆå*¨7¸4¼>ÐJÑJÔJð 		>ð 		>ˆHØ˜=Ð(Ð(Øåœ7Ÿ<š<­¬	©¬°T´^ÀXÑNÔNˆLÝœŸš¨Ñ6Ô6¸+ÑFˆJà˜RÒÐÕ(;¸LÑ(IÔ(IÐÕR`ÐamÑRnÔRnÐØ—’˜xÑ(Ô(Ð(Ø,×3Ò3°HÑ=Ô=Ð=øð 	×Ò˜Ñ'Ô'Ð'à+Ð+r.   c                 ó"  — 	 t          ¦   «         5  t          d|rdnd› �| j        ¦  «        }t                               |j        ¦  «         ddd¦  «         dS # 1 swxY w Y   dS # t          j        $ r}t          |j	        ¦  «        ‚d}~ww xY w)aŸ  
        git lfs prune

        Args:
            recent (`bool`, *optional*, defaults to `False`):
                Whether to prune files even if they were referenced by recent
                commits. See the following
                [link](https://github.com/git-lfs/git-lfs/blob/f3d43f0428a84fc4f1e5405b76b5a73ec2437e65/docs/man/git-lfs-prune.1.ronn#recent-files)
                for more information.
        zgit lfs prune z--recentr$   N©
rî   r   rô   rá   r  r>   rL   rv   r¡   r:   )r+   Úrecentr1   r~   s       r,   Ú	lfs_prunezRepository.lfs_pruneÅ  så   € ð	/Ý"Ñ$Ô$ð +ð +Ý'Ð(WÀvÐ9U¸¸ÐSUÐ(WÐ(WÐY]ÔYgÑhÔh�Ý—’˜FœMÑ*Ô*Ð*ð+ð +ð +ñ +ô +ð +ð +ð +ð +ð +ð +ð +øøøð +ð +ð +ð +ð +ð +øõ Ô,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs:   ‚A& �<AÁA& ÁAÁA& Á AÁ!A& Á&BÁ5B	Â	BÚrebaserr   c                 ó.  — |sdnd}|r|dz  }	 t          ¦   «         5  t          || j        ¦  «        }t                               |j        ¦  «         ddd¦  «         dS # 1 swxY w Y   dS # t          j        $ r}t          |j	        ¦  «        ‚d}~ww xY w)a7  
        git pull

        Args:
            rebase (`bool`, *optional*, defaults to `False`):
                Whether to rebase the current branch on top of the upstream
                branch after fetching.
            lfs (`bool`, *optional*, defaults to `False`):
                Whether to fetch the LFS files too. This option only changes the
                behavior when a repository was cloned without fetching the LFS
                files; calling `repo.git_pull(lfs=True)` will then fetch the LFS
                file from the remote repository.
        zgit pullzgit lfs pullz	 --rebaseNr^  )r+   ra  rr   Úcommandr1   r~   s         r,   Úgit_pullzRepository.git_pull×  sò   € ð %(Ð;�*�*¨^ˆØð 	#Ø�{Ñ"ˆGð	/Ý"Ñ$Ô$ð +ð +Ý'¨°´Ñ@Ô@�Ý—’˜FœMÑ*Ô*Ð*ð+ð +ð +ñ +ô +ð +ð +ð +ð +ð +ð +ð +øøøð +ð +ð +ð +ð +ð +øõ Ô,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs:   �A, �5AÁA, ÁA#Á#A, Á&A#Á'A, Á,BÁ;BÂBÚauto_lfs_trackc                 ó¸  — |r]|                       |¦  «        }|                     |                      |¦  «        ¦  «         |rt                               d|› d�¦  «         	 t          d                     ¦   «         |gz   | j        ¦  «        }t                               d|j	        › d�¦  «         dS # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w)a7  
        git add

        Setting the `auto_lfs_track` parameter to `True` will automatically
        track files that are larger than 10MB with `git-lfs`.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to add files to staging.
            auto_lfs_track (`bool`, *optional*, defaults to `False`):
                Whether to automatically track large and binary files with
                git-lfs. Any file over 10MB in size, or in binary format, will
                be automatically tracked.
        z!Adding files tracked by Git LFS: z5. This may take a bit of time if the files are large.z
git add -vzAdding to index:
rq   N)r\  ÚextendrZ  rá   r+  r   rZ   rô   r  r>   rL   rv   r¡   r:   )r+   rŸ   re  Útracked_filesr1   r~   s         r,   Úgit_addzRepository.git_addï  sø   € ð ð 	à ×7Ò7¸Ñ@Ô@ˆMð × Ò  ×!=Ò!=¸gÑ!FÔ!FÑGÔGÐGàð Ý—’ð;¸ð ;ð ;ð ;ñô ð ð
	/Ý# L×$6Ò$6Ñ$8Ô$8¸G¸9Ñ$DÀdÄnÑUÔUˆFÝ�KŠKÐ>¨V¬]Ð>Ð>Ð>Ñ?Ô?Ð?Ð?Ð?øÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøs   Á!AB1 Â1CÃ CÃCúcommit files to HF hubÚcommit_messagec                 óR  — 	 t          d                     ¦   «         |gz   | j        ¦  «        }t                               d|j        › d�¦  «         dS # t          j        $ rE}t          |j	        ¦  «        dk    rt          |j	        ¦  «        ‚t          |j        ¦  «        ‚d}~ww xY w)z·
        git commit

        Args:
            commit_message (`str`, *optional*, defaults to "commit files to HF hub"):
                The message attributed to the commit.
        zgit commit -v -mzCommitted:
rq   r   N)r   rZ   rô   rá   r  r>   rL   rv   rx   r:   r¡   )r+   rk  r1   r~   s       r,   Ú
git_commitzRepository.git_commit  sª   € ð	3Ý#Ð$6×$<Ò$<Ñ$>Ô$>À.ÐAQÑ$QÐSWÔSaÑbÔbˆFÝ�KŠKÐ8 v¤}Ð8Ð8Ð8Ñ9Ô9Ð9Ð9Ð9øÝÔ,ð 	3ð 	3ð 	3Ý�3”:‰Œ Ò"Ð"Ý& s¤zÑ2Ô2Ð2å& s¤zÑ2Ô2Ð2øøøøð		3øøøs   ‚AA ÁB&Á!A B!Â!B&r§   ÚblockingÚauto_lfs_prunec                 ó  ‡— d}|r|d|› �z  }t          | j        |¦  «        }|dk    r:t                               d|› d�¦  «         |rt                               d¦  «         	 t	          ¦   «         5  t          j        |                     ¦   «         t
          j        t
          j        d| j        ¬¦  «        Š|r‡‰ 	                    ¦   «         \  }}‰ 
                    ¦   «         }‰                     ¦   «          t          |¦  «        rt                               |¦  «         |rt          j        |‰j        ||¬	¦  «        ‚d
d
d
¦  «         n# 1 swxY w Y   n+# t
          j        $ r}	t          |	j        ¦  «        ‚d
}	~	ww xY w|sUˆfd„}
t#          dˆfd„|
‰|r| j        nd
¬¦  «        }| j                             |¦  «         |                      ¦   «         |fS |r|                      ¦   «          |                      ¦   «         S )a%  
        git push

        If used without setting `blocking`, will return url to commit on remote
        repo. If used with `blocking=True`, will return a tuple containing the
        url to commit and the command object to follow for information about the
        process.

        Args:
            upstream (`str`, *optional*):
                Upstream to which this should push. If not specified, will push
                to the lastly defined upstream or to the default one (`origin
                main`).
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the push has
                finished. Setting this to `False` will return an
                `CommandInProgress` object which has an `is_done` property. This
                property will be set to `True` when the push is finished.
            auto_lfs_prune (`bool`, *optional*, defaults to `False`):
                Whether to automatically prune files once they have been pushed
                to the remote.
        zgit pushz --set-upstream r   zSeveral commits (z) will be pushed upstream.z$The progress bars may be unreliable.zutf-8)r:   r>   ÚencodingrT   )r1  r:   Nc                  ó8   •— ‰                      ¦   «         } | €dS | S )Nr@   ©Úpoll)r5   r!   s    €r,   r    z*Repository.git_push.<locals>.status_methodd  s   ø€ Ø Ÿš™œ�Ø�>Ø˜2à!�Mr.   Úpushc                  ó0   •— ‰                       ¦   «         d uS rF   rs  )r!   s   €r,   ú<lambda>z%Repository.git_push.<locals>.<lambda>m  s   ø€  w§|¢|¡~¤~¸TÐ'A€ r.   )r   r    r!   r"   )r©   rô   rá   r+  rî   rL   rM   rZ   r[   Úcommunicatert  Úkillrx   rv   rß   r¡   r:   r   r`  rñ   rU  r=  )r+   r§   rn  ro  rc  Únumber_of_commitsr>   r:   Úreturn_coder~   r    Úcommand_in_progressr!   s               @r,   Úgit_pushzRepository.git_push"  s˜  ø€ ð8 ˆàð 	5ØÐ4¨(Ð4Ð4Ñ4ˆGå+¨D¬N¸HÑEÔEÐà˜qÒ Ð Ý�NŠNÐ\Ð/@Ð\Ð\Ð\Ñ]Ô]Ð]Øð GÝ—’ÐEÑFÔFÐFð	/Ý"Ñ$Ô$ð uð uÝ$Ô*Ø—M’M‘O”OÝ%œ?Ý%œ?Ø$Øœðñ ô �ð ð 	uØ%,×%8Ò%8Ñ%:Ô%:‘N�F˜FØ")§,¢,¡.¤.�KØ—L’L‘N”N�Nå˜6‘{”{ð /ÝŸš vÑ.Ô.Ð.à"ð uÝ(Ô;¸KÈÌÐ^dÐmsÐtÑtÔtÐtð%uð uð uñ uô uð uð uð uð uð uð uøøøð uð uð uð uøøõ( Ô,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøð ð 	Cð"ð "ð "ð "ð "õ #4ØØAÐAÐAÐAØ+ØØ.<ÐF˜DœN˜NÀ$ð#ñ #ô #Ðð Ô×%Ò%Ð&9Ñ:Ô:Ð:à×+Ò+Ñ-Ô-Ð/BÐBÐBàð 	Ø�NŠNÑÔÐà×'Ò'Ñ)Ô)Ð)s=   Á$E Á2CEÅ E ÅEÅE ÅEÅE ÅF Å'E;Å;F r  c                 ó2  — 	 t          d|› �| j        ¦  «        }t                               d|› d| j        › d�¦  «         t                               |j        ¦  «         d	S # t          j        $ r¦}|st          |j	        ¦  «        ‚	 t          d|› �| j        ¦  «        }t                               d|› d|› d�¦  «         t                               |j        ¦  «         n+# t          j        $ r}t          |j	        ¦  «        ‚d	}~ww xY wY d	}~d	S d	}~ww xY w)
a  
        git checkout a given revision

        Specifying `create_branch_ok` to `True` will create the branch to the
        given revision if that revision doesn't exist.

        Args:
            revision (`str`):
                The revision to checkout.
            create_branch_ok (`str`, *optional*, defaults to `False`):
                Whether creating a branch named with the `revision` passed at
                the current checked-out reference if `revision` isn't an
                existing revision is allowed.
        zgit checkout zChecked out z from rž   zgit checkout -b z
Revision `z2` does not exist. Created and checked out branch `z`.N)
r   rô   rá   r+  r  r>   rL   rv   r¡   r:   )r+   rú   r  r1   r~   s        r,   r  zRepository.git_checkout|  sI  € ð	7Ý#Ð$>°HÐ$>Ð$>ÀÄÑOÔOˆFÝ�NŠNÐP¨(ÐPÐP¸$Ô:MÐPÐPÐPÑQÔQÐQÝ�NŠN˜6œ=Ñ)Ô)Ð)Ð)Ð)øÝÔ,ð 	7ð 	7ð 	7Ø#ð 
7Ý& s¤zÑ2Ô2Ð2ð7Ý+Ð,I¸xÐ,IÐ,IÈ4Ì>ÑZÔZ�FÝ—N’NØm XÐmÐmÐaiÐmÐmÐmñô ð õ —N’N 6¤=Ñ1Ô1Ð1Ð1øÝ!Ô4ð 7ð 7ð 7Ý*¨3¬:Ñ6Ô6Ð6øøøøð7øøøð 2Ð1Ð1Ð1Ð1Ð1øøøøð	7øøøs=   ‚AA! Á!DÁ0DÂAC ÃDÃ DÃ/DÄDÄDÄDÚtag_namerh   c                 óÈ  — |ro	 t          d|› �| j        ¦  «        j                             ¦   «         }n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY wt          |¦  «        dk    S 	 t          d| j        ¦  «        j                             ¦   «         }n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w| 	                    d¦  «        }||v S )aw  
        Check if a tag exists or not.

        Args:
            tag_name (`str`):
                The name of the tag to check.
            remote (`str`, *optional*):
                Whether to check if the tag exists on a remote. This parameter
                should be the identifier of the remote.

        Returns:
            `bool`: Whether the tag exists.
        zgit ls-remote origin refs/tags/Nr   zgit tagrq   rD  )r+   r  rh   r1   r~   Úgit_tagss         r,   Ú
tag_existszRepository.tag_existsœ  sú   € ð ð 	(ð3Ý'Ð(TÈ(Ð(TÐ(TÐVZÔVdÑeÔeÔl×rÒrÑtÔt��øÝÔ0ð 3ð 3ð 3Ý& s¤zÑ2Ô2Ð2øøøøð3øøøõ �v‘;”; !Ò#Ð#ð3Ý)¨)°T´^ÑDÔDÔK×QÒQÑSÔS��øÝÔ0ð 3ð 3ð 3Ý& s¤zÑ2Ô2Ð2øøøøð3øøøð  —~’~ dÑ+Ô+ˆHØ˜xÐ'Ð's-   „/4 ´AÁAÁAÁ3,B  Â CÂ/CÃCc                 óò  — d}d}|                       |¦  «        sd}|                       ||¬¦  «        sd}|r]	 t          ddd|g| j        ¦  «        j                             ¦   «          n+# t
          j        $ r}t          |j        ¦  «        ‚d}~ww xY w|ra|r_	 t          d|› d	|› �| j        ¦  «        j                             ¦   «          n+# t
          j        $ r}t          |j        ¦  «        ‚d}~ww xY wdS )
a˜  
        Delete a tag, both local and remote, if it exists

        Args:
            tag_name (`str`):
                The tag name to delete.
            remote (`str`, *optional*):
                The remote on which to delete the tag.

        Returns:
             `bool`: `True` if deleted, `False` if the tag didn't exist.
                If remote is not passed, will just be updated locally
        TF)rh   Úgitr�   z-dNú	git push z
 --delete )	r‚  r   rô   r>   ru   rL   rv   r¡   r:   )r+   r  rh   Údelete_locallyÚdelete_remotelyr~   s         r,   Ú
delete_tagzRepository.delete_tagº  s4  € ð ˆØˆà�Š˜xÑ(Ô(ð 	#Ø"ˆNà�Š˜x°ˆÑ7Ô7ð 	$Ø#ˆOàð 	3ð3Ý  u¨d°HÐ=¸t¼~ÑNÔNÔU×[Ò[Ñ]Ô]Ð]Ð]øÝÔ0ð 3ð 3ð 3Ý& s¤zÑ2Ô2Ð2øøøøð3øøøð ð 	3�oð 	3ð3ÝÐG¨6ÐGÐG¸XÐGÐGÈÌÑXÔXÔ_×eÒeÑgÔgÐgÐgøÝÔ0ð 3ð 3ð 3Ý& s¤zÑ2Ô2Ð2øøøøð3øøøð ˆts/   ¸0A) Á)BÁ8BÂBÂ2C ÃC4ÃC/Ã/C4ró   c                 óœ  — |r	ddd|d|g}ndd|g}	 t          || j        ¦  «        j                             ¦   «          n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY w|r`	 t          d|› d|› �| j        ¦  «        j                             ¦   «          dS # t          j        $ r}t          |j        ¦  «        ‚d}~ww xY wdS )a[  
        Add a tag at the current head and push it

        If remote is None, will just be updated locally

        If no message is provided, the tag will be lightweight. if a message is
        provided, the tag will be annotated.

        Args:
            tag_name (`str`):
                The name of the tag to be added.
            message (`str`, *optional*):
                The message that accompanies the tag. The tag will turn into an
                annotated tag if a message is passed.
            remote (`str`, *optional*):
                The remote on which to add the tag.
        r„  r�   z-az-mNr…  r#  r  )r+   r  ró   rh   Útag_argsr~   s         r,   Úadd_tagzRepository.add_tagß  s
  € ð$ ð 	0Ø˜u d¨H°d¸GÐDˆHˆHà˜u hÐ/ˆHð	/Ý˜8 T¤^Ñ4Ô4Ô;×AÒAÑCÔCÐCÐCøÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøð ð 	3ð3ÝÐ>¨6Ð>Ð>°HÐ>Ð>ÀÄÑOÔOÔV×\Ò\Ñ^Ô^Ð^Ð^Ð^øÝÔ0ð 3ð 3ð 3Ý& s¤zÑ2Ô2Ð2øøøøð3øøøð	3ð 	3s-   ’,? ¿A'ÁA"Á"A'Á-2B! Â!C	Â0CÃC	c                 óÚ   — 	 t          d| j        ¦  «        j                             ¦   «         }n+# t          j        $ r}t          |j        ¦  «        ‚d}~ww xY wt          |¦  «        dk    S )z¢
        Return whether or not the git status is clean or not

        Returns:
            `bool`: `True` if the git status is clean, `False` otherwise.
        zgit status --porcelainNr   )	r   rô   r>   ru   rL   rv   r¡   r:   rx   )r+   rE  r~   s      r,   Úis_repo_cleanzRepository.is_repo_clean  so   € ð	/Ý'Ð(@À$Ä.ÑQÔQÔX×^Ò^Ñ`Ô`ˆJˆJøÝÔ,ð 	/ð 	/ð 	/Ý" 3¤:Ñ.Ô.Ð.øøøøð	/øøøõ �:‰Œ !Ò#Ð#r  Úclean_okc                 óü   — |r0|                       ¦   «         rt                               d¦  «         dS |                      d¬¦  «         |                      |¦  «         |                      d| j        › �||¬¦  «        S )aF  
        Helper to add, commit, and push files to remote repository on the
        HuggingFace Hub. Will automatically track large files (>10MB).

        Args:
            commit_message (`str`):
                Message to use for the commit.
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the `git push` has
                finished.
            clean_ok (`bool`, *optional*, defaults to `True`):
                If True, this function will return None if the repo is
                untouched. Default behavior is to fail because the git command
                fails.
            auto_lfs_prune (`bool`, *optional*, defaults to `False`):
                Whether to automatically prune files once they have been pushed
                to the remote.
        z*Repo currently clean. Ignoring push_to_hubNT©re  úorigin ©r§   rn  ro  )r�  rá   r  ri  rm  r}  r  )r+   rk  rn  rŽ  ro  s        r,   Úpush_to_hubzRepository.push_to_hub  sŒ   € ð2 ð 	˜×*Ò*Ñ,Ô,ð 	Ý�KŠKÐDÑEÔEÐEØ�4Ø�Š DˆÑ)Ô)Ð)Ø�Š˜Ñ'Ô'Ð'Ø�}Š}Ø4˜tÔ2Ð4Ð4ØØ)ð ñ 
ô 
ð 	
r.   ÚbranchÚtrack_large_filesc              #   óÊ  K  — t          d| j        ¬¦  «        }t          |¦  «        rbt          |¦  «        dk    r"t          |dd…         ¦  «        dd…         dz   nt          |¦  «        }t                               d|› d�¦  «         |�|                      |d	¬
¦  «         t          | j        ¦  «        r1t                               d¦  «         |  	                    d	¬¦  «         n#t                               d| j
        › d�¦  «         t          j        ¦   «         }t          j        t          j                             || j        ¦  «        ¦  «         	 | V — |                      |¬¦  «         	 |                      |¦  «         n*# t$          $ r}	dt          |	¦  «        vr|	‚Y d}	~	nd}	~	ww xY w	 |                      d| j
        › �||¬¦  «         n5# t$          $ r(}	dt          |	¦  «        v rt%          d¦  «        |	‚|	‚d}	~	ww xY wt          j        |¦  «         dS # |                      |¬¦  «         	 |                      |¦  «         n*# t$          $ r}	dt          |	¦  «        vr|	‚Y d}	~	nd}	~	ww xY w	 |                      d| j
        › �||¬¦  «         n5# t$          $ r(}	dt          |	¦  «        v rt%          d¦  «        |	‚|	‚d}	~	ww xY wt          j        |¦  «         w xY w)a…  
        Context manager utility to handle committing to a repository. This
        automatically tracks large files (>10Mb) with git-lfs. Set the
        `track_large_files` argument to `False` if you wish to ignore that
        behavior.

        Args:
            commit_message (`str`):
                Message to use for the commit.
            branch (`str`, *optional*):
                The branch on which the commit will appear. This branch will be
                checked-out before any operation.
            track_large_files (`bool`, *optional*, defaults to `True`):
                Whether to automatically track large files or not. Will do so by
                default.
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the `git push` has
                finished.
            auto_lfs_prune (`bool`, defaults to `True`):
                Whether to automatically prune files once they have been pushed
                to the remote.

        Examples:

        ```python
        >>> with Repository(
        ...     "text-files",
        ...     clone_from="<user>/text-files",
        ...     token=True,
        >>> ).commit("My first file :)"):
        ...     with open("file.txt", "w+") as f:
        ...         f.write(json.dumps({"hey": 8}))

        >>> import torch

        >>> model = torch.nn.Transformer()
        >>> with Repository(
        ...     "torch-model",
        ...     clone_from="<user>/torch-model",
        ...     token=True,
        >>> ).commit("My cool model :)"):
        ...     torch.save(model.state_dict(), "model.pt")
        ```

        rž   rR  é   Nr@   z, ...]zPThere exists some updated files in the local repository that are not committed: z|. This may lead to errors if checking out a branch. These files and their modifications will be added to the current commit.Tr  zPulling changes ...)ra  z@The current branch has no upstream branch. Will push to 'origin ú'r�  znothing to commitr‘  r’  zcould not read UsernamezCCouldn't authenticate user for push. Did you set `token` to `True`?)r£   rô   rx   rK   rá   rÖ   r  r¦   r+  rd  r  rU   r  ÚchdirrV   rX   ri  rm  rw   r}  )
r+   rk  r”  r•  rn  ro  Úfiles_to_stageÚfiles_in_msgÚcurrent_working_directoryÚes
             r,   ÚcommitzRepository.commit3  s€  è è € õn ,¨C¸¼ÐGÑGÔGˆåˆ~ÑÔð 	ÝFIÈ.ÑFYÔFYÐ\]ÒF]ÐF]�3˜~¨b¨q¨bÔ1Ñ2Ô2°3°B°3Ô7¸(ÑBÐBÕcfÐguÑcvÔcvˆLÝ�LŠLð#Ø+ð#ð #ð #ñô ð ð ÐØ×Ò˜f°tÐÑ<Ô<Ð<å˜tœ~Ñ.Ô.ð 	vÝ�NŠNÐ0Ñ1Ô1Ð1Ø�MŠM ˆMÑ&Ô&Ð&Ð&å�NŠNÐtÐ^bÔ^qÐtÐtÐtÑuÔuÐuå$&¤I¡K¤KÐ!Ý
Œ•”—’Ð7¸¼ÑHÔHÑIÔIÐIð	0ØˆJˆJˆJà�LŠLÐ(9ˆLÑ:Ô:Ð:ðØ—’ Ñ/Ô/Ð/Ð/øÝð ð ð à&­c°!©f¬fÐ4Ð4Ø�Gð 5Ð4Ð4Ð4Ð4øøøøðøøøð
Ø—’Ø< tÔ':Ð<Ð<Ø%Ø#1ð ñ ô ð ð øõ
 ð ð ð à,µ°A±´Ð6Ð6Ý!Ð"gÑhÔhÐnoÐoà�Gøøøøðøøøõ ŒHÐ.Ñ/Ô/Ð/Ð/Ð/øð- �LŠLÐ(9ˆLÑ:Ô:Ð:ðØ—’ Ñ/Ô/Ð/Ð/øÝð ð ð à&­c°!©f¬fÐ4Ð4Ø�Gð 5Ð4Ð4Ð4Ð4øøøøðøøøð
Ø—’Ø< tÔ':Ð<Ð<Ø%Ø#1ð ñ ô ð ð øõ
 ð ð ð à,µ°A±´Ð6Ð6Ý!Ð"gÑhÔhÐnoÐoà�Gøøøøðøøøõ ŒHÐ.Ñ/Ô/Ð/Ð/øøøsŠ   ÅH Å1F Æ
F.ÆF)Æ)F.Æ2 G Ç
HÇ#H È HÈK"È6IÉK"É
I3ÉI.É)K"É.I3É3K"É7 JÊK"Ê
K
Ê"#KËK
Ë
K"c                 óÀ   — t           j                             | j        t          j        ¦  «        }t           j                             |¦  «        rt          |¦  «        S d S rF   )rU   rV   rX   rô   r   ÚREPOCARD_NAMEÚisfiler   )r+   Úfilepaths     r,   Úrepocard_metadata_loadz!Repository.repocard_metadata_loadœ  sE   € Ý”7—<’< ¤µ	Ô0GÑHÔHˆÝŒ7�>Š>˜(Ñ#Ô#ð 	+Ý  Ñ*Ô*Ð*Øˆtr.   Údatac                 ó|   — t          t          j                             | j        t
          j        ¦  «        |¦  «        S rF   )r   rU   rV   rX   rô   r   r   )r+   r¤  s     r,   Úrepocard_metadata_savez!Repository.repocard_metadata_save¢  s(   € Ý�RœWŸ\š\¨$¬.½)Ô:QÑRÔRÐTXÑYÔYÐYr.   c                 ó$   — d„ | j         D ¦   «         S )z@
        Returns the asynchronous commands that failed.
        c                 ó(   — g | ]}|j         d k    ¯|‘ŒS )r   r7   ©rg   Úcs     r,   ri   z.Repository.commands_failed.<locals>.<listcomp>ª  s   € Ð>Ð>Ð>�a°´¸A²°�°°°r.   ©rñ   r4   s    r,   Úcommands_failedzRepository.commands_failed¥  s   € ð
 ?Ð>˜4Ô-Ð>Ñ>Ô>Ð>r.   c                 ó$   — d„ | j         D ¦   «         S )zS
        Returns the asynchronous commands that are currently in progress.
        c                 ó    — g | ]}|j         °	|‘ŒS rQ   )r2   r©  s     r,   ri   z3Repository.commands_in_progress.<locals>.<listcomp>±  s   € Ð?Ð?Ð?�a°Q´YÐ?�Ð?Ð?Ð?r.   r«  r4   s    r,   Úcommands_in_progresszRepository.commands_in_progress¬  s   € ð
 @Ð?˜4Ô-Ð?Ñ?Ô?Ð?r.   c                 óf  — d}| j         D ]Q}t                               d|j        › d|j        j        › d�¦  «         t                               |j        ¦  «         ŒR| j        rN|dz  dk    r#t                               d| j        › d�¦  «         |dz  }t          j
        d¦  «         | j        °Ld	S d	S )
zr
        Blocking method: blocks all subsequent execution until all commands have
        been processed.
        r   zThe z command with PID z failed.r�   zCWaiting for the following commands to finish before shutting down: rž   r   N)r¬  rá   rÖ   r   r'   rD   r:   r¯  r+  r¿   rÀ   )r+   ÚindexÚcommand_faileds      r,   r  zRepository.wait_for_commands³  sÛ   € ð
 ˆØ"Ô2ð 	0ð 	0ˆNÝ�LŠLÐm Ô 4ÐmÐmÈÔH_ÔHcÐmÐmÐmÑnÔnÐnÝ�LŠL˜Ô.Ñ/Ô/Ð/Ð/àÔ'ð 	Ø�r‰z˜QŠˆÝ—’ØvÐZ^ÔZsÐvÐvÐvñô ð ð �Q‰JˆEåŒJ�q‰MŒMˆMð Ô'ð 	ð 	ð 	ð 	ð 	r.   )NNTNNNFNrF   )NN)F)rž   )FF)rž   F)rj  )NTF)rj  TTF)NTTF)3rG   rH   rI   rJ   r   r   r®   r   r   r   rK   r   r	   rO   r   r-   rN   r  r  rõ   r  r  r7  r:  r=  rI  rL  rN  r  rZ  r\  r`  rd  ri  rm  r
   r}  r  r‚  rˆ  r‹  r�  r“  r   rž  r   r£  r¦  r¬  r¯  r  rQ   r.   r,   rð   rð   ª  s]  € € € € € € ðð ð" Ð)Ô*Ð*Ð*Ñ*àØÐØðQðñ ô ð %)Ø#'Ø"&Ø"&Ø#'Ø"&Ø$Ø"&ðj0ð j0à˜˜d˜Ô#ðj0ð ˜S”Mðj0ð ˜C”=ð	j0ð
 �T˜3�YÔðj0ð ˜3”-ðj0ð ˜C”=ðj0ð ˜3”-ðj0ð ðj0ð ˜”ðj0ð j0ð j0ñô ñ Ôðj0ðX ð ð ð ð ñ „Xðð6ð 6ð 6ð. ð}/ð }/ 3ð }/¨u°T¸3À°_Ô/Eð }/ð }/ð }/ñ Ôð}/ð~/ð /°h¸s´mð /ÐW_Ð`cÔWdð /ð /ð /ð /ð&/ð /ð /ð/˜sð /ð /ð /ð /ð/ ð /ð /ð /ð /ð% Sð %ð %ð %ð %ð! D¨¤Ið !ð !ð !ð !ðF/ð / %¨¨T°#¬Y¨Ô"7ð /À4ð /ð /ð /ð /ð2/ E¨#¨t°C¬y¨.Ô$9ð /ð /ð /ð /ð /ð /ð /ð),ð ),¨sð ),¸TÀ#¼Yð ),ð ),ð ),ð ),ðV,ð ,¨cð ,¸DÀ¼Ið ,ð ,ð ,ð ,ðB/ð /ð /ð /ð$/ð /˜tð /°$ð /ð /ð /ð /ð0 /ð  /˜sð  /¸$ð  /ð  /ð  /ð  /ðD3ð 3¨ð 3ð 3ð 3ð 3ð& #'ØØ$ð	X*ð X*à˜3”-ðX*ð ðX*ð ð	X*ð
 
ˆs�E˜#Ð0Ð0Ô1Ð1Ô	2ðX*ð X*ð X*ð X*ðt7ð 7 Sð 7¸Dð 7ð 7ð 7ð 7ð@(ð ( 3ð (°¸´ð (Èð (ð (ð (ð (ð<#ð # 3ð #°¸´ð #Èð #ð #ð #ð #ðJ 3ð  3 ð  3¨h°s¬mð  3ÈHÐUXÌMð  3ð  3ð  3ð  3ðD$˜tð $ð $ð $ð $ð  7ØØØ$ð"
ð "
àð"
ð ð"
ð ð	"
ð
 ð"
ð 
ˆt�S˜% Ð%6Ð 6Ô7Ð7Ô	8ð"
ð "
ð "
ð "
ðH ð !%Ø"&ØØ$ðf0ð f0àðf0ð ˜”ðf0ð  ð	f0ð
 ðf0ð ðf0ð f0ð f0ñ „^ðf0ðP¨°¬ð ð ð ð ðZ¨4ð Z°Dð Zð Zð Zð Zð ð?ð ?ñ „Xð?ð ð@ð @ñ „Xð@ðð ð ð ð r.   rð   )rž   NrF   ):r  rU   re   rL   rå   r¿   Ú
contextlibr   Úpathlibr   Útypingr   r   r   r   r	   r
   r   r   Úurllib.parser   Úhuggingface_hubr   Úhuggingface_hub.repocardr   r   Úhf_apir   r   rr   r   Úutilsr   r   r   r   r   r   Úutils._deprecationr   Ú
get_loggerrG   rá   r   rK   rO   r_   rk   r‚   r‡   r�   r£   r¦   rP   r©   r«   rî   rð   rQ   r.   r,   ú<module>r½     s¾  ðØ €€€Ø 	€	€	€	Ø 	€	€	€	Ø Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TØ !Ð !Ð !Ð !Ð !Ð !à %Ð %Ð %Ð %Ð %Ð %Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ Aà 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø -Ð -Ð -Ð -Ð -Ð -ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 2Ð 1Ð 1Ð 1Ð 1Ð 1ð 
ˆÔ	˜HÑ	%Ô	%€ðP
ð P
ð P
ð P
ð P
ñ P
ô P
ð P
ðf8˜˜c 4˜iÔ(ð 8¨Tð 8ð 8ð 8ð 8ð"!˜5  d Ô+ð !¸ð !Àð !ð !ð !ð !ð2"' %¨¨T¨	Ô"2ð "'°tð "'ð "'ð "'ð "'ðJ˜U 3¨ 9Ô-ð °$ð ð ð ð ð2˜U 3¨ 9Ô-ð °$ð ð ð ð ð.ð  ð °5¸¸dÀD¸Ô3Ið ÐUYÐZ]ÔU^ð ð ð ð ð2  c¨4 iÔ 0ð °Tð ð ð ð ð,+ð +˜E # t )Ô,ð +¸À¼ð +ÐQTð +ð +ð +ð +ð,ð ð ð ð ˆIñ ô ð ð ðjHð jHñ „ðjHðZ[ð [ð [ð [ð [ñ [ô [ð [ð [ð [r.   