9
9
group_meta_key = '.zgroup'
10
10
attrs_key = '.zattrs'
11
11
12
+ Path = Union [str , bytes , None ]
13
+
12
14
13
15
class BaseStore (MutableMapping ):
14
16
"""Abstract base class for store implementations.
@@ -118,11 +120,11 @@ class Store(BaseStore):
118
120
119
121
"""
120
122
121
- def listdir (self , path : str = "" ) -> List [str ]:
123
+ def listdir (self , path : Path = None ) -> List [str ]:
122
124
path = normalize_storage_path (path )
123
125
return _listdir_from_keys (self , path )
124
126
125
- def rmdir (self , path : str = "" ) -> None :
127
+ def rmdir (self , path : Path = None ) -> None :
126
128
if not self .is_erasable ():
127
129
raise NotImplementedError (
128
130
f'{ type (self )} is not erasable, cannot call "rmdir"'
@@ -150,15 +152,7 @@ def _rename_from_keys(store: BaseStore, src_path: str, dst_path: str) -> None:
150
152
store [new_key ] = store .pop (key )
151
153
152
154
153
- def _rmdir_from_keys (store : Union [BaseStore , MutableMapping ], path : Optional [str ] = None ) -> None :
154
- # assume path already normalized
155
- prefix = _path_to_prefix (path )
156
- for key in list (store .keys ()):
157
- if key .startswith (prefix ):
158
- del store [key ]
159
-
160
-
161
- def _listdir_from_keys (store : BaseStore , path : Optional [str ] = None ) -> List [str ]:
155
+ def _listdir_from_keys (store : BaseStore , path : Optional [Path ] = None ) -> List [str ]:
162
156
# assume path already normalized
163
157
prefix = _path_to_prefix (path )
164
158
children = set ()
@@ -168,3 +162,11 @@ def _listdir_from_keys(store: BaseStore, path: Optional[str] = None) -> List[str
168
162
child = suffix .split ('/' )[0 ]
169
163
children .add (child )
170
164
return sorted (children )
165
+
166
+
167
+ def _rmdir_from_keys (store : Union [BaseStore , MutableMapping ], path : Optional [Path ] = None ) -> None :
168
+ # assume path already normalized
169
+ prefix = _path_to_prefix (path )
170
+ for key in list (store .keys ()):
171
+ if key .startswith (prefix ):
172
+ del store [key ]
0 commit comments