CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
git.cpython-310.pyc50 linesDownload Raw Back to __pycache__
1o

2��Yi��@s<ddlZddlZddlmZddlmZGdd�de�ZdS)�N)�AbstractFileSystem�)�3MemoryFilecs�eZdZdZdZdZd�fdd�	Ze�fdd��Zd	d4�Z	e5dd��Ze6dd
d��Zddd�Z
ddd�Zddd�Z					ddd�Z�ZS)�
GitFileSystemz\Browse the files of a local git repo at any hash/tag/branch7 8    (experimental backend)9    �TNcs8t�jdi|��t�|p|pt���|_|pd|_dS)aM10 11        Parameters12        ----------13        path: str (optional)14            Local location of the repo (uses current directory if not given).15            May be deprecated in favour of ``fo``. When used with a higher16            level function such as fsspec.open(), may be of the form17            "git://[path-to-repo[:]][ref@]path/to/file" (but the actual18            file path should not contain "@" or ":").19        fo: str (optional)20            Same as ``path``, but passed as part of a chained URL. This one21            takes precedence if both are given.22        ref: str (optional)23            Reference to work with, could be a hash, tag or branch name. Defaults24            to current working tree. Note that ``ls`` and ``open`` also take hash,25            so this becomes the default for those operations26        kwargs27        ZmasterN�)�super�__init__�pygit2Z28Repository�os�getcwd�repo�ref)�self�path�for�kwargs��	__class__r��E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\fsspec/implementations/git.pyr	szGitFileSystem.__init__csLt��|��d�}d|vr|�dd�d}d|vr!|�dd�d}|�d�S)N�/�:r�@)r�_strip_protocol�lstrip�split)�clsrrrrr+s29zGitFileSystem._strip_protocolcCs\|j�|p|j�\}}|�d�}|j}|D]}|r+t|tj�r+||vr't|��||}q|S)Nr)	r
Zresolve_refishrr�tree�30isinstancer31�Tree�FileNotFoundError)rrrZcomm�partsr�partrrr�_path_to_object4s32�zGitFileSystem._path_to_objectcCsJ|�d�}i}d|vr|�dd�\|d<}d|vr#|�dd�\|d<}|S)Nzgit://rrrrr)�removeprefixr)r�outrrr�_get_kwargs_from_urls?s33z#GitFileSystem._get_kwargs_from_urlscCslt|tj�}|r34dnd|rd�||jpdg��d�n|jt|j�|jdur'dn|jd�|r1dd�S|j	d�S)	N�	directory�filerrZ100644�or)�type�name�hex�mode�size)35rr36r�joinr+r�str�id�filemoder.)�objr�is_dirrrr�_object_to_infoIs37"��zGitFileSystem._object_to_infocs<|�|���|�}��fdd�t|tj�r|D�S|gD�S)Ncs,g|]}�rt�|��nt�|��d�qS)r+)rr5)�.0r3��detailrrr�38<listcomp>Ys���z$GitFileSystem.ls.<locals>.<listcomp>)r#rrr39r)rrr8rrrrr7r�lsWs��zGitFileSystem.lscKs|�|�|�|�}t�||�S�N)r#rrr5)rrrrrrrr�info`szGitFileSystem.infocCs|j||d�dS)N)rr,)r<)rrrrrr�ukeydszGitFileSystem.ukey�rbc	Ks|�||p|j�}t|jd�S)N)�data)r#rrr?)	rrr-�40block_sizeZ41autocommitZ
cache_optionsrrr3rrr�_opengs42zGitFileSystem._open)NNNr;)TN)r>NTNN)�__name__�43__module__�__qualname__�__doc__Zroot_markerZcachabler	�classmethodrr#�staticmethodr&r5r:r<r=rA�
__classcell__rrrrr44s*45	46
47	48�r)rr49Zfsspec.specrZmemoryrrrrrr�<module>s50
Aluode/PerceptionLabPortable · CoolFace