
    7Th                     B    S SK r S SKrS SKJr  SSKJr   " S S\5      rg)    N)AbstractFileSystem   )
MemoryFilec                      ^  \ rS rSrSrSrSrSU 4S jjr\U 4S j5       r	S r
\S 5       r\SS	 j5       rSS
 jrSS jrSS jr     SS jrSrU =r$ )GitFileSystem
   zTBrowse the files of a local git repo at any hash/tag/branch

(experimental backend)
 Tc                    > [         TU ]  " S0 UD6  [        R                  " U=(       d    U=(       d    [        R
                  " 5       5      U l        U=(       d    SU l        g)a  

Parameters
----------
path: str (optional)
    Local location of the repo (uses current directory if not given).
    May be deprecated in favour of ``fo``. When used with a higher
    level function such as fsspec.open(), may be of the form
    "git://[path-to-repo[:]][ref@]path/to/file" (but the actual
    file path should not contain "@" or ":").
fo: str (optional)
    Same as ``path``, but passed as part of a chained URL. This one
    takes precedence if both are given.
ref: str (optional)
    Reference to work with, could be a hash, tag or branch name. Defaults
    to current working tree. Note that ``ls`` and ``open`` also take hash,
    so this becomes the default for those operations
kwargs
masterN )super__init__pygit2
Repositoryosgetcwdreporef)selfpathfor   kwargs	__class__s        R/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/implementations/git.pyr   GitFileSystem.__init__   sB    ( 	"6"%%b&?D&?BIIK@	?(    c                    > [         TU ]  U5      R                  S5      nSU;   a  UR                  SS5      S   nSU;   a  UR                  SS5      S   nUR                  S5      $ )N/:r   @)r   _strip_protocollstripsplit)clsr   r   s     r   r!   GitFileSystem._strip_protocol+   sd    w&t,33C8$;::c1%a(D$;::c1%a(D{{3r   c                 .   U R                   R                  U=(       d    U R                  5      u  p2UR                  S5      nUR                  nU HA  nU(       d  M  [        U[        R                  5      (       d  M-  Xe;  a  [        U5      eXV   nMC     U$ )Nr   )	r   resolve_refishr   r#   tree
isinstancer   TreeFileNotFoundError)r   r   r   commpartsr(   parts          r   _path_to_objectGitFileSystem._path_to_object4   st    II,,S_DHH=	

3yyDt
455#+D11z	 
 r   c                     U R                  S5      (       a  U SS  n 0 nSU ;   a  U R                  SS5      u  US'   n SU ;   a  U R                  SS5      u  US'   n U$ )Nzgit://   r   r   r   r    r   )
startswithr#   )r   outs     r   _get_kwargs_from_urls#GitFileSystem._get_kwargs_from_urls?   sf    ??8$$8D$; $

3 2CK$;#zz#q1CJ
r   c                 h   [        U [        R                  5      nU(       a  SOSU(       a4  SR                  XR                  =(       d    S/5      R                  S5      OU R                  [        U R                  5      U R                  c  SOU R                  S U(       a  SS.$ U R                  S.$ )	N	directoryfiler   r	   100644or   )typenamehexmodesize)
r)   r   r*   joinr=   r"   stridfilemoder@   )objr   is_dirs      r   _object_to_infoGitFileSystem._object_to_infoJ   s     C-#)Kv@D$B/077<#((svv; # 4HS\\!<LA
 	
 &)XX
 	
r   c                    U R                  U R                  U5      U5      n[        U[        R                  5      (       a  UOU/ Vs/ s H7  nU(       a  [
        R                  Xa5      O[
        R                  Xa5      S   PM9     sn$ s  snf )Nr=   )r/   r!   r)   r   r*   r   rG   )r   r   detailr   r   r(   rE   s          r   lsGitFileSystem.lsX   s    ##D$8$8$>D
 !+4 = =D6I	
 J  ))#4..s9&AB J	
 	
 
s   >B	c                 n    U R                  U R                  U5      U5      n[        R                  XA5      $ N)r/   r!   r   rG   )r   r   r   r   r(   s        r   infoGitFileSystem.infoa   s0    ##D$8$8$>D,,T88r   c                 &    U R                  XS9S   $ )N)r   r>   )rO   )r   r   r   s      r   ukeyGitFileSystem.ukeye   s    yyy'..r   c                 p    U R                  X=(       d    U R                  5      n[        UR                  S9$ )N)data)r/   r   r   rU   )	r   r   r?   
block_size
autocommitcache_optionsr   r   rE   s	            r   _openGitFileSystem._openh   s+     ""49sxx((r   )r   r   )NNNrN   )TN)rbNTNN)__name__
__module____qualname____firstlineno____doc__root_markercachabler   classmethodr!   r/   staticmethodr5   rG   rK   rO   rR   rY   __static_attributes____classcell__)r   s   @r   r   r   
   s    
 KH#0    	   
 

9/ ) )r   r   )r   r   fsspec.specr   memoryr   r   r   r   r   <module>ri      s     	  * i)& i)r   