1616)
1717from zarr .core .buffer import Buffer
1818from zarr .errors import ZarrUserWarning
19- from zarr .storage ._utils import _join_paths , normalize_path
19+ from zarr .storage ._utils import _dereference_path
2020
2121if TYPE_CHECKING :
2222 from collections .abc import AsyncIterator , Iterable
@@ -127,7 +127,7 @@ def __init__(
127127 ) -> None :
128128 super ().__init__ (read_only = read_only )
129129 self .fs = fs
130- self .path = normalize_path ( path )
130+ self .path = path
131131 self .allowed_exceptions = allowed_exceptions
132132
133133 if not self .fs .async_impl :
@@ -282,7 +282,7 @@ async def get(
282282 # docstring inherited
283283 if not self ._is_open :
284284 await self ._open ()
285- path = _join_paths ([ self .path , key ] )
285+ path = _dereference_path ( self .path , key )
286286
287287 try :
288288 if byte_range is None :
@@ -329,7 +329,7 @@ async def set(
329329 raise TypeError (
330330 f"FsspecStore.set(): `value` must be a Buffer instance. Got an instance of { type (value )} instead."
331331 )
332- path = _join_paths ([ self .path , key ] )
332+ path = _dereference_path ( self .path , key )
333333 # write data
334334 if byte_range :
335335 raise NotImplementedError
@@ -338,7 +338,7 @@ async def set(
338338 async def delete (self , key : str ) -> None :
339339 # docstring inherited
340340 self ._check_writable ()
341- path = _join_paths ([ self .path , key ] )
341+ path = _dereference_path ( self .path , key )
342342 try :
343343 await self .fs ._rm (path )
344344 except FileNotFoundError :
@@ -354,14 +354,14 @@ async def delete_dir(self, prefix: str) -> None:
354354 )
355355 self ._check_writable ()
356356
357- path_to_delete = _join_paths ([ self .path , prefix ] )
357+ path_to_delete = _dereference_path ( self .path , prefix )
358358
359359 with suppress (* self .allowed_exceptions ):
360360 await self .fs ._rm (path_to_delete , recursive = True )
361361
362362 async def exists (self , key : str ) -> bool :
363363 # docstring inherited
364- path = _join_paths ([ self .path , key ] )
364+ path = _dereference_path ( self .path , key )
365365 exists : bool = await self .fs ._exists (path )
366366 return exists
367367
@@ -378,7 +378,7 @@ async def get_partial_values(
378378 starts : list [int | None ] = []
379379 stops : list [int | None ] = []
380380 for key , byte_range in key_ranges :
381- paths .append (_join_paths ([ self .path , key ] ))
381+ paths .append (_dereference_path ( self .path , key ))
382382 if byte_range is None :
383383 starts .append (None )
384384 stops .append (None )
@@ -408,7 +408,7 @@ async def get_partial_values(
408408 async def list (self ) -> AsyncIterator [str ]:
409409 # docstring inherited
410410 allfiles = await self .fs ._find (self .path , detail = False , withdirs = False )
411- for onefile in (a .removeprefix (self .path + " /" ) for a in allfiles ):
411+ for onefile in (a .removeprefix (f" { self .path } /" ) for a in allfiles ):
412412 yield onefile
413413
414414 async def list_dir (self , prefix : str ) -> AsyncIterator [str ]:
@@ -418,7 +418,7 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
418418 allfiles = await self .fs ._ls (prefix , detail = False )
419419 except FileNotFoundError :
420420 return
421- for onefile in (a .replace (prefix + " /" , "" ) for a in allfiles ):
421+ for onefile in (a .replace (f" { prefix } /" , "" ) for a in allfiles ):
422422 yield onefile .removeprefix (self .path ).removeprefix ("/" )
423423
424424 async def list_prefix (self , prefix : str ) -> AsyncIterator [str ]:
@@ -429,7 +429,7 @@ async def list_prefix(self, prefix: str) -> AsyncIterator[str]:
429429 yield onefile .removeprefix (f"{ self .path } /" )
430430
431431 async def getsize (self , key : str ) -> int :
432- path = _join_paths ([ self .path , key ] )
432+ path = _dereference_path ( self .path , key )
433433 info = await self .fs ._info (path )
434434
435435 size = info .get ("size" )
0 commit comments