Skip to content

Commit

Permalink
simplify string handling
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Aug 3, 2024
1 parent ebbfbe0 commit da6083e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/zarr/store/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
to_strip = str(self.root) + "/"
for p in (self.root / prefix).rglob("*"):
if p.is_file():
yield str(p).replace(to_strip, "")
yield str(p).removeprefix(to_strip)

async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
"""
Expand Down
6 changes: 1 addition & 5 deletions src/zarr/store/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
yield onefile

async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
if prefix == "":
find_str = "/".join([self.path, prefix])
else:
find_str = "/".join([self.path, prefix])

find_str = "/".join([self.path, prefix])
for onefile in await self._fs._find(find_str):
yield onefile.removeprefix(find_str)

0 comments on commit da6083e

Please sign in to comment.