From 9849449d7a995d6f4567f5cae9f500acc44b16ac Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 19 Aug 2024 19:25:46 -0700 Subject: [PATCH] Support Pathlib --- src/hdmf_zarr/backend.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hdmf_zarr/backend.py b/src/hdmf_zarr/backend.py index a70e2e4..78e2ef5 100644 --- a/src/hdmf_zarr/backend.py +++ b/src/hdmf_zarr/backend.py @@ -48,6 +48,9 @@ from hdmf.query import HDMFDataset from hdmf.container import Container +from pathlib import Path + + # Module variables ROOT_NAME = 'root' """ @@ -84,7 +87,7 @@ def can_read(path): return False @docval({'name': 'path', - 'type': (str, *SUPPORTED_ZARR_STORES), + 'type': (str, Path, *SUPPORTED_ZARR_STORES), 'doc': 'the path to the Zarr file or a supported Zarr store'}, {'name': 'manager', 'type': BuildManager, 'doc': 'the BuildManager to use for I/O', 'default': None}, {'name': 'mode', 'type': str, @@ -115,6 +118,8 @@ def __init__(self, **kwargs): else: self.__synchronizer = synchronizer self.__mode = mode + if isinstance(path, Path): + path = str(path) self.__path = path self.__file = None self.__storage_options = storage_options @@ -195,7 +200,7 @@ def is_remote(self): 'type': (NamespaceCatalog, TypeMap), 'doc': 'the NamespaceCatalog or TypeMap to load namespaces into'}, {'name': 'path', - 'type': (str, *SUPPORTED_ZARR_STORES), + 'type': (str, Path, *SUPPORTED_ZARR_STORES), 'doc': 'the path to the Zarr file or a supported Zarr store'}, {'name': 'storage_options', 'type': dict, 'doc': 'Zarr storage options to read remote folders',