From c3a3cbadd429fb80a2afdeb181ad94f2c7c030ff Mon Sep 17 00:00:00 2001 From: jim Date: Mon, 12 Oct 2015 14:36:07 -0500 Subject: [PATCH 1/2] resolves #101: No longer assumes a date will always be present in the metadata and falls back by displayed "Unknown" in the Nd2 repr --- Makefile | 2 +- nd2reader/interface.py | 2 +- nd2reader/model/metadata.py | 2 +- nd2reader/parser/v3.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c6af2e3..58e9178 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ test: build docker run --rm -it jimrybarski/nd2reader python3.4 /opt/nd2reader/tests.py docker run --rm -it jimrybarski/nd2reader python2.7 /opt/nd2reader/tests.py -functest: build +ftest: build docker run --rm -v ~/nd2s:/var/nd2s -it jimrybarski/nd2reader python3.4 /opt/nd2reader/ftests.py docker run --rm -v ~/nd2s:/var/nd2s -it jimrybarski/nd2reader python2.7 /opt/nd2reader/ftests.py diff --git a/nd2reader/interface.py b/nd2reader/interface.py index a0d1d4f..05e673f 100644 --- a/nd2reader/interface.py +++ b/nd2reader/interface.py @@ -28,7 +28,7 @@ class Nd2(object): def __repr__(self): return "\n".join(["" % self._filename, - "Created: %s" % self.date, + "Created: %s" % self.date if self.date is not None else "Unknown", "Image size: %sx%s (HxW)" % (self.height, self.width), "Frames: %s" % len(self.frames), "Channels: %s" % ", ".join(["'%s'" % str(channel) for channel in self.channels]), diff --git a/nd2reader/model/metadata.py b/nd2reader/model/metadata.py index 11a0164..536f0b9 100644 --- a/nd2reader/model/metadata.py +++ b/nd2reader/model/metadata.py @@ -35,7 +35,7 @@ class Metadata(object): """ The date and time when acquisition began. - :rtype: datetime.datetime() + :rtype: datetime.datetime() or None """ return self._date diff --git a/nd2reader/parser/v3.py b/nd2reader/parser/v3.py index f8bc7fd..e71c3c1 100644 --- a/nd2reader/parser/v3.py +++ b/nd2reader/parser/v3.py @@ -59,7 +59,7 @@ class V3Parser(BaseParser): """ The date and time when acquisition began. - :rtype: datetime.datetime() + :rtype: datetime.datetime() or None """ for line in metadata_dict[six.b('ImageTextInfo')][six.b('SLxImageTextInfo')].values(): @@ -78,7 +78,7 @@ class V3Parser(BaseParser): if not absolute_start_12 and not absolute_start_24: continue return absolute_start_12 if absolute_start_12 else absolute_start_24 - raise ValueError("This ND2 has no recorded start time. This is probably a bug.") + return None def _parse_channels(self, metadata_dict): """ From 2e6611b02729f050f45718209ee95d774785e32c Mon Sep 17 00:00:00 2001 From: jim Date: Mon, 12 Oct 2015 14:53:54 -0500 Subject: [PATCH 2/2] #101: Shows the text "Created:" even if there is no creation date --- nd2reader/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nd2reader/interface.py b/nd2reader/interface.py index 05e673f..997bfc1 100644 --- a/nd2reader/interface.py +++ b/nd2reader/interface.py @@ -28,7 +28,7 @@ class Nd2(object): def __repr__(self): return "\n".join(["" % self._filename, - "Created: %s" % self.date if self.date is not None else "Unknown", + "Created: %s" % (self.date if self.date is not None else "Unknown"), "Image size: %sx%s (HxW)" % (self.height, self.width), "Frames: %s" % len(self.frames), "Channels: %s" % ", ".join(["'%s'" % str(channel) for channel in self.channels]),