diff --git a/bioio_ome_zarr/reader.py b/bioio_ome_zarr/reader.py index 8b7ebd0..9eac3db 100644 --- a/bioio_ome_zarr/reader.py +++ b/bioio_ome_zarr/reader.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import warnings +from pathlib import Path from typing import Any, Dict, List, Optional, Tuple import xarray as xr @@ -80,6 +81,25 @@ def _is_supported_image(fs: AbstractFileSystem, path: str, **kwargs: Any) -> boo except AttributeError: return False + @classmethod + def is_supported_image( + cls, + image: types.ImageLike, + fs_kwargs: Dict[str, Any] = {}, + **kwargs: Any, + ) -> bool: + if isinstance(image, (str, Path)): + try: + ZarrReader(parse_url(image, mode="r")) + return True + + except AttributeError: + return False + else: + return reader.Reader.is_supported_image( + cls, image, fs_kwargs=fs_kwargs, **kwargs + ) + @property def scenes(self) -> Tuple[str, ...]: if self._scenes is None: