Skip to content

Commit 7b52e39

Browse files
committed
Move utility functions into ABSStore class
1 parent 13a6d30 commit 7b52e39

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

zarr/storage.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,24 +1885,6 @@ def __delitem__(self, key):
18851885
self._invalidate_value(key)
18861886

18871887

1888-
# utility functions for object stores
1889-
1890-
1891-
def _strip_prefix_from_path(path, prefix):
1892-
# normalized things will not have any leading or trailing slashes
1893-
path_norm = normalize_storage_path(path)
1894-
prefix_norm = normalize_storage_path(prefix)
1895-
if path_norm.startswith(prefix_norm):
1896-
return path_norm[(len(prefix_norm)+1):]
1897-
else:
1898-
return path
1899-
1900-
1901-
def _append_path_to_prefix(path, prefix):
1902-
return '/'.join([normalize_storage_path(prefix),
1903-
normalize_storage_path(path)])
1904-
1905-
19061888
class ABSStore(MutableMapping):
19071889
"""Storage class using Azure Blob Storage (ABS).
19081890
@@ -1951,6 +1933,10 @@ def __enter__(self):
19511933
def __exit__(self, *args):
19521934
pass
19531935

1936+
def _append_path_to_prefix(path, prefix):
1937+
return '/'.join([normalize_storage_path(prefix),
1938+
normalize_storage_path(path)])
1939+
19541940
def full_path(self, path=None):
19551941
return _append_path_to_prefix(path, self.prefix)
19561942

@@ -2000,6 +1986,15 @@ def list_abs_subdirectories(self, prefix):
20001986
"""Return list of all "subdirectories" from an abs prefix."""
20011987
return list(set([blob.name.rsplit('/', 1)[0] for blob in self.client.list_blobs(self.container_name) if '/' in blob.name]))
20021988

1989+
def _strip_prefix_from_path(path, prefix):
1990+
# normalized things will not have any leading or trailing slashes
1991+
path_norm = normalize_storage_path(path)
1992+
prefix_norm = normalize_storage_path(prefix)
1993+
if path_norm.startswith(prefix_norm):
1994+
return path_norm[(len(prefix_norm)+1):]
1995+
else:
1996+
return path
1997+
20031998
def list_abs_directory(self, prefix, strip_prefix=True):
20041999
"""Return a list of all blobs and subdirectories from an abs prefix."""
20052000
items = set()

0 commit comments

Comments
 (0)