mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
repofs: use fs.ls
This commit is contained in:
@@ -50,3 +50,6 @@ class GitFileSystem(FSSpecWrapper): # pylint:disable=abstract-method
|
||||
@property
|
||||
def rev(self) -> str:
|
||||
return self.fs.rev
|
||||
|
||||
def ls(self, path, **kwargs):
|
||||
return self.fs.ls(path, **kwargs) or []
|
||||
|
||||
@@ -147,6 +147,9 @@ class LocalFileSystem(FileSystem):
|
||||
def info(self, path):
|
||||
return self.fs.info(path)
|
||||
|
||||
def ls(self, path, **kwargs):
|
||||
return self.fs.ls(path, **kwargs)
|
||||
|
||||
def put_file(
|
||||
self, from_file, to_info, callback=DEFAULT_CALLBACK, **kwargs
|
||||
):
|
||||
|
||||
+16
-12
@@ -28,13 +28,12 @@ def _ls(fs, path):
|
||||
dnames = []
|
||||
fnames = []
|
||||
|
||||
with suppress(FileNotFoundError):
|
||||
for entry in fs.ls(path, detail=True):
|
||||
name = fs.path.name(entry["name"])
|
||||
if entry["type"] == "directory":
|
||||
dnames.append(name)
|
||||
else:
|
||||
fnames.append(name)
|
||||
for entry in fs.ls(path, detail=True):
|
||||
name = fs.path.name(entry["name"])
|
||||
if entry["type"] == "directory":
|
||||
dnames.append(name)
|
||||
else:
|
||||
fnames.append(name)
|
||||
|
||||
return dnames, fnames
|
||||
|
||||
@@ -362,15 +361,20 @@ class RepoFileSystem(FileSystem): # pylint:disable=abstract-method
|
||||
|
||||
assert dvcignore
|
||||
|
||||
dvc_dirs, dvc_fnames = _ls(dvc_fs, dvc_path) if dvc_fs else ([], [])
|
||||
dvc_dirs, dvc_fnames = [], []
|
||||
if dvc_fs:
|
||||
with suppress(FileNotFoundError):
|
||||
dvc_dirs, dvc_fnames = _ls(dvc_fs, dvc_path)
|
||||
|
||||
try:
|
||||
_, repo_dirs, repo_fnames = next(
|
||||
dvcignore.walk(fs, fs_path, **kwargs)
|
||||
)
|
||||
except StopIteration:
|
||||
repo_dirs, repo_fnames = _ls(fs, fs_path)
|
||||
except FileNotFoundError:
|
||||
return
|
||||
|
||||
repo_dirs, repo_fnames = dvcignore(
|
||||
fs_path, repo_dirs, repo_fnames, **kwargs
|
||||
)
|
||||
|
||||
# separate subdirs into shared dirs, dvc-only dirs, repo-only dirs
|
||||
dvc_set = set(dvc_dirs)
|
||||
repo_set = set(repo_dirs)
|
||||
|
||||
Reference in New Issue
Block a user