mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-05 23:09:32 +01:00
* build(deps-dev): bump scmrepo from 0.1.6 to 0.1.7 Bumps [scmrepo](https://github.com/iterative/scmrepo) from 0.1.6 to 0.1.7. - [Release notes](https://github.com/iterative/scmrepo/releases) - [Commits](https://github.com/iterative/scmrepo/compare/0.1.6...0.1.7) --- updated-dependencies: - dependency-name: scmrepo dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * mypy: remove scmrepo from ignored modules * Fix mypy issues --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: skshetry <[email protected]> Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
import functools
|
|
from typing import TYPE_CHECKING, Any, Optional
|
|
|
|
from . import FileSystem
|
|
|
|
if TYPE_CHECKING:
|
|
from scmrepo.fs import GitFileSystem as FsspecGitFileSystem
|
|
from scmrepo.git.objects import GitTrie
|
|
|
|
from dvc.scm import Git
|
|
|
|
|
|
class GitFileSystem(FileSystem): # pylint:disable=abstract-method
|
|
"""Proxies the repo file access methods to Git objects"""
|
|
|
|
protocol = "local"
|
|
PARAM_CHECKSUM = "md5"
|
|
|
|
def __init__(
|
|
self,
|
|
path: Optional[str] = None,
|
|
rev: Optional[str] = None,
|
|
scm: Optional["Git"] = None,
|
|
trie: Optional["GitTrie"] = None,
|
|
**kwargs: Any,
|
|
) -> None:
|
|
from dvc.scm import resolve_rev
|
|
|
|
super().__init__()
|
|
self.fs_args.update(
|
|
{
|
|
"path": path,
|
|
"rev": rev,
|
|
"scm": scm,
|
|
"trie": trie,
|
|
"rev_resolver": resolve_rev,
|
|
**kwargs,
|
|
}
|
|
)
|
|
|
|
@functools.cached_property
|
|
def fs( # pylint: disable=invalid-overridden-method
|
|
self,
|
|
) -> "FsspecGitFileSystem":
|
|
from scmrepo.fs import GitFileSystem as FsspecGitFileSystem
|
|
|
|
return FsspecGitFileSystem(**self.fs_args)
|
|
|
|
@functools.cached_property
|
|
def path(self): # pylint: disable=invalid-overridden-method
|
|
return self.fs.path
|
|
|
|
@property
|
|
def rev(self) -> str:
|
|
return self.fs.rev
|
|
|
|
def ls(self, path, detail=True, **kwargs):
|
|
return self.fs.ls(path, detail=detail, **kwargs) or []
|