From af83d0a178f3bf7a122eaf6aad21604f3ef66c55 Mon Sep 17 00:00:00 2001 From: skshetry Date: Thu, 20 Oct 2022 09:54:25 +0545 Subject: [PATCH] fsspec: move more api to fsspec localfs (#162) --- src/dvc_objects/fs/local.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/dvc_objects/fs/local.py b/src/dvc_objects/fs/local.py index 5010d14..71e76ef 100644 --- a/src/dvc_objects/fs/local.py +++ b/src/dvc_objects/fs/local.py @@ -22,23 +22,18 @@ def __init__(self, *args, **kwargs): self.fs = fsspec.filesystem("file") def makedirs(self, path, exist_ok=False): - makedirs(path, exist_ok=exist_ok) + self.fs.makedirs(path, exist_ok=exist_ok) def mkdir(self, path, create_parents=True, **kwargs): - if self.exists(path): - raise FileExistsError(path) - if create_parents: - self.makedirs(path, exist_ok=True) - else: - os.mkdir(path, **kwargs) + self.fs.mkdir(path, create_parents=create_parents, **kwargs) def lexists(self, path, **kwargs): - return os.path.lexists(path) + return self.fs.lexists(path, **kwargs) def exists(self, path, **kwargs): # TODO: replace this with os.path.exists once the problem is fixed on # the fsspec https://github.com/intake/filesystem_spec/issues/742 - return os.path.lexists(path) + return self.lexists(path) def checksum(self, path) -> str: from fsspec.utils import tokenize @@ -112,7 +107,7 @@ def mv(self, path1, path2, **kwargs): move(path1, path2) def rmdir(self, path): - os.rmdir(path) + self.fs.rmdir(path) def rm_file(self, path): remove(path)