Skip to content

Commit

Permalink
Merge pull request #342 from dstansby/fsspec-pin
Browse files Browse the repository at this point in the history
Unpin fsspec in dev requirements
  • Loading branch information
joshmoore committed Jan 31, 2024
2 parents f2160a7 + 2093851 commit 2dad835
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions ome_zarr/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,45 @@ def get_json(self, subpath: str) -> JSONDict:
return {}

def parts(self) -> List[str]:
if self.__store.fs.protocol == "file":
if self._isfile():
return list(Path(self.__path).parts)
else:
return self.__path.split("/")

def subpath(self, subpath: str = "") -> str:
if self.__store.fs.protocol == "file":
if self._isfile():
filename = Path(self.__path) / subpath
filename = filename.resolve()
return str(filename)
if self.__store.fs.protocol in ["http", "https"]:
elif self._ishttp():
url = str(self.__path)
if not url.endswith("/"):
url = f"{url}/"
return urljoin(url, subpath)
else:
# Might require a warning
if self.__path.endswith("/"):
return f"{self.__path}{subpath}"
else:
return f"{self.__path}/{subpath}"

def _isfile(self) -> bool:
"""
Return whether the current underlying implementation
points to a local file or not.
"""
return self.__store.fs.protocol == "file" or self.__store.fs.protocol == (
"file",
"local",
)

def _ishttp(self) -> bool:
"""
Return whether the current underlying implementation
points to a URL
"""
return self.__store.fs.protocol in ["http", "https"]


def parse_url(
path: Union[Path, str], mode: str = "r", fmt: Format = CurrentFormat()
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fsspec==2023.6.0
fsspec
black
cython >= 0.29.16
numpy >= 1.16.0
Expand Down

0 comments on commit 2dad835

Please sign in to comment.