Skip to content

Commit fcfb1e9

Browse files
committed
rename ls to listdir for consistency with python standard library naming
1 parent 4968961 commit fcfb1e9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

zarr/storage.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def rm(store, prefix=None):
119119
del store[key]
120120

121121

122-
def _ls_from_keys(store, prefix=None):
122+
def _listdir_from_keys(store, prefix=None):
123123
children = set()
124124
for key in store.keys():
125125
if key.startswith(prefix) and len(key) > len(prefix):
@@ -129,13 +129,13 @@ def _ls_from_keys(store, prefix=None):
129129
return sorted(children)
130130

131131

132-
def ls(store, prefix=None):
132+
def listdir(store, prefix=None):
133133
"""TODO"""
134134
prefix = normalize_prefix(prefix)
135-
if hasattr(store, 'ls'):
136-
return store.ls(prefix)
135+
if hasattr(store, 'listdir'):
136+
return store.listdir(prefix)
137137
else:
138-
return _ls_from_keys(store, prefix)
138+
return _listdir_from_keys(store, prefix)
139139

140140

141141
def init_array(store, shape, chunks, dtype=None, compression='default',
@@ -318,9 +318,9 @@ class DirectoryStore(MutableMapping):
318318
b'xxx'
319319
>>> sorted(store.keys())
320320
['foo', 'a/b/c']
321-
>>> store.ls()
321+
>>> store.listdir()
322322
['a', 'foo']
323-
>>> store.ls('a/b')
323+
>>> store.listdir('a/b')
324324
['c']
325325
>>> store.rm('a')
326326
>>> sorted(store.keys())
@@ -415,7 +415,7 @@ def __iter__(self):
415415
def __len__(self):
416416
return sum(1 for _ in self.keys())
417417

418-
def ls(self, prefix):
418+
def listdir(self, prefix):
419419
path = os.path.join(self.path, normalize_prefix(prefix))
420420
return sorted(os.listdir(path))
421421

@@ -425,7 +425,7 @@ def rm(self, prefix):
425425
shutil.rmtree(path)
426426

427427
def getsize(self, prefix):
428-
children = self.ls(prefix)
428+
children = self.listdir(prefix)
429429
size = 0
430430
for child in children:
431431
path = os.path.join(self.path, child)
@@ -500,16 +500,16 @@ def __contains__(self, key):
500500
else:
501501
return True
502502

503-
def ls(self, prefix):
503+
def listdir(self, prefix):
504504
prefix = normalize_prefix(prefix)
505-
return _ls_from_keys(self, prefix)
505+
return _listdir_from_keys(self, prefix)
506506

507507
def rm(self, prefix):
508508
raise NotImplementedError
509509

510510
def getsize(self, prefix):
511511
prefix = normalize_prefix(prefix)
512-
children = self.ls(prefix)
512+
children = self.listdir(prefix)
513513
size = 0
514514
with zipfile.ZipFile(self.path) as zf:
515515
for child in children:

0 commit comments

Comments
 (0)