L iBddlZddlZddlmZddlmZGddeZy)N)AbstractFileSystem) MemoryFileceZdZdZdZdZd fd ZefdZdZ e dZ e ddZ dd Z dd Zdd Z dd ZxZS) GitFileSystemz\Browse the files of a local git repo at any hash/tag/branch (experimental backend) Tc t|di|tj|xs|xst j |_|xsd|_y)aM 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 Repositoryosgetcwdreporef)selfpathforkwargs __class__s `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fsspec/implementations/git.pyr zGitFileSystem.__init__sB( "6"%%b&?D&?BIIK@ ?(ct||jd}d|vr|jddd}d|vr|jddd}|jdS)N/:r@)r _strip_protocollstripsplit)clsrrs rrzGitFileSystem._strip_protocol+sdw&t,33C8 $;::c1%a(D $;::c1%a(D{{3rc |jj|xs |j\}}|jd}|j}|D]4}|st |t js!||vr t|||}6|S)Nr) rresolve_refishrr!tree isinstancerTreeFileNotFoundError)rrrcommpartsr%parts r_path_to_objectzGitFileSystem._path_to_object4szII,,S_DHH= c 3yy "D 45t#+D11Dz  "  rc|jd}i}d|vr|jdd\|d<}d|vr|jdd\|d<}|S)Nzgit://rrrrr) removeprefixr!)routs r_get_kwargs_from_urlsz#GitFileSystem._get_kwargs_from_urls?s\  * $; $ 3 2 CK $;#zz#q1 CJ rc@t|tj}|rdnd|r0dj||jxsdgj dn |jt |j|jdn |jd|rddS|jdS) N directoryfilerr100644or)typenamehexmodesize) r&rr'joinr7r stridfilemoder:)objris_dirs r_object_to_infozGitFileSystem._object_to_infoIsC-#)Kv@D$B/077<#((svv; # 4HS\\!D !+4 =D6    ) )#t 4..sD9&A B   s8A>c p|j|j||}tj||SN)r,rrrA)rrrrr%s rinfozGitFileSystem.info`s2##D$8$8$>D,,T488rc.|j||dS)N)rr8)rG)rrrs rukeyzGitFileSystem.ukeydsyy3y'..rc n|j||xs |j}t|jS)N)data)r,rrrK) rrr9 block_size autocommit cache_optionsrrr?s r_openzGitFileSystem._opengs-""49sxx((r)NNNrF)TN)rbNTNN)__name__ __module__ __qualname____doc__ root_markercachabler classmethodrr, staticmethodr0rArDrGrIrO __classcell__)rs@rrr s KH#0        9/   )rr)rr fsspec.specrmemoryrrr rrr\s  *h)&h)r