Skip to content

Commit

Permalink
make 2 utils public
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Feb 18, 2022
1 parent 41fdc78 commit 974a70d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/nd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
__version__ = "unknown"
__author__ = "Talley Lambert"
__email__ = "talley.lambert@gmail.com"
__all__ = ["ND2File", "imread", "structures"]
__all__ = ["ND2File", "imread", "structures", "AXIS", "is_supported_file"]


from . import structures
from ._util import AXIS, is_supported_file
from .nd2file import ND2File, imread
6 changes: 3 additions & 3 deletions src/nd2/_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from datetime import datetime
from typing import TYPE_CHECKING, NamedTuple, Union
from typing import IO, TYPE_CHECKING, Any, Callable, NamedTuple, Union

if TYPE_CHECKING:
from ._legacy import LegacyND2Reader
Expand All @@ -12,8 +12,8 @@
VERSION = re.compile(r"^ND2 FILE SIGNATURE CHUNK NAME01!Ver([\d\.]+)$")


def is_supported_file(path):
with open(path, "rb") as fh:
def is_supported_file(path, open_: Callable[[str, str], IO[Any]] = open):
with open_(path, "rb") as fh:
return fh.read(4) in (NEW_HEADER_MAGIC, OLD_HEADER_MAGIC)


Expand Down

0 comments on commit 974a70d

Please sign in to comment.