From a8007ac6c5eb7de03298dbdcc6be59d3c282e125 Mon Sep 17 00:00:00 2001 From: yzx9 Date: Fri, 5 Apr 2024 10:50:31 +0800 Subject: [PATCH] refactor(images): add directory check --- swcgeom/images/folder.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swcgeom/images/folder.py b/swcgeom/images/folder.py index 67ba15b..5797dce 100644 --- a/swcgeom/images/folder.py +++ b/swcgeom/images/folder.py @@ -62,6 +62,9 @@ def _read(self, fname: str) -> npt.NDArray[ScalarType]: @staticmethod def scan(root: str, *, pattern: Optional[str] = None) -> List[str]: + if not os.path.isdir(root): + raise NotADirectoryError(f"not a directory: {root}") + is_valid = re.compile(pattern).match if pattern is not None else truthly fs = []