10000 Implement rmdir · benjeffery/zarr-python@a85e559 · GitHub
[go: up one dir, main page]

Skip to content

Commit a85e559

Browse files
committed
Implement rmdir
1 parent e5564c3 commit a85e559

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

zarr/storage.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,15 @@ def __setstate__(self, state):
20892089
self.__dict__.update(state)
20902090
self.initialize_container()
20912091

2092+
def __enter__(self):
2093+
return self
2094+
2095+
def __exit__(self, *args):
2096+
pass
2097+
2098+
def full_path(self, path=None):
2099+
return _append_path_to_prefix(path, self.prefix)
2100+
20922101
def __getitem__(self, key):
20932102
blob_name = '/'.join([self.prefix, key])
20942103
blob = self.client.get_blob_to_bytes(self.container_name, blob_name)
@@ -2164,7 +2173,9 @@ def rename(self, src_path, dst_path):
21642173
raise NotImplementedErrror
21652174

21662175
def rmdir(self, path=None):
2167-
raise NotImplementedErrror
2176+
dir_path = normalize_storage_path(self.full_path(path)) + '/'
2177+
for blob in self.client.list_blobs(self.container_name, dir_path):
2178+
self.client.delete_blob(self.container_name, blob.name)
21682179

21692180
def getsize(self, path=None):
21702181
dir_path = self.dir_path(path)

0 commit comments

Comments
 (0)
0