From 2b2ad95a821bb0b7e76e3cdb18fc5dbaa84d82ca Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Fri, 9 Oct 2015 21:57:29 -0500 Subject: [PATCH] fixed syntax errors --- Makefile | 6 +++--- nd2reader/common/__init__.py | 0 nd2reader/common/v3.py | 20 ++++++++++++++++++++ nd2reader/driver/v3.py | 2 +- nd2reader/interface.py | 2 +- nd2reader/parser/v3.py | 20 +------------------- setup.py | 4 ---- 7 files changed, 26 insertions(+), 28 deletions(-) create mode 100644 nd2reader/common/__init__.py create mode 100644 nd2reader/common/v3.py diff --git a/Makefile b/Makefile index 7906c9d..29c890b 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,13 @@ build: docker build -t jimrybarski/nd2reader . shell: - xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader bash + xhost local:root; docker run --rm -v ~/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader bash py2: - xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python2.7 + xhost local:root; docker run --rm -v ~/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python2.7 py3: - xhost local:root; docker run --rm -v ~/Documents/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python3.4 + xhost local:root; docker run --rm -v ~/nd2s:/var/nd2s -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$(DISPLAY) -it jimrybarski/nd2reader python3.4 test: build docker run --rm -it jimrybarski/nd2reader python3.4 /opt/nd2reader/tests.py diff --git a/nd2reader/common/__init__.py b/nd2reader/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nd2reader/common/v3.py b/nd2reader/common/v3.py new file mode 100644 index 0000000..2c33c7e --- /dev/null +++ b/nd2reader/common/v3.py @@ -0,0 +1,20 @@ +import struct + + +def read_chunk(fh, chunk_location): + """ + Gets the data for a given chunk pointer + + :rtype: bytes + + """ + fh.seek(chunk_location) + # The chunk metadata is always 16 bytes long + chunk_metadata = fh.read(16) + header, relative_offset, data_length = struct.unpack("IIQ", chunk_metadata) + if header != 0xabeceda: + raise ValueError("The ND2 file seems to be corrupted.") + # We start at the location of the chunk metadata, skip over the metadata, and then proceed to the + # start of the actual data field, which is at some arbitrary place after the metadata. + fh.seek(chunk_location + 16 + relative_offset) + return fh.read(data_length) diff --git a/nd2reader/driver/v3.py b/nd2reader/driver/v3.py index e7a3484..6fe0300 100644 --- a/nd2reader/driver/v3.py +++ b/nd2reader/driver/v3.py @@ -5,7 +5,7 @@ import numpy as np import struct import six from nd2reader.model.image import Image -from nd2reader.parser.v3 import read_chunk +from nd2reader.common.v3 import read_chunk class V3Driver(object): diff --git a/nd2reader/interface.py b/nd2reader/interface.py index b62e4d7..54d8607 100644 --- a/nd2reader/interface.py +++ b/nd2reader/interface.py @@ -163,4 +163,4 @@ class Nd2(object): return self._driver.get_image_by_attributes(frame_number, field_of_view, channel_name, z_level) def close(self): - self._fh.close() \ No newline at end of file + self._fh.close() diff --git a/nd2reader/parser/v3.py b/nd2reader/parser/v3.py index ab0bbd1..f8bc7fd 100644 --- a/nd2reader/parser/v3.py +++ b/nd2reader/parser/v3.py @@ -5,30 +5,12 @@ from datetime import datetime from nd2reader.model.metadata import Metadata from nd2reader.parser.base import BaseParser from nd2reader.driver.v3 import V3Driver +from nd2reader.common.v3 import read_chunk import re import six import struct -def read_chunk(fh, chunk_location): - """ - Gets the data for a given chunk pointer - - :rtype: bytes - - """ - fh.seek(chunk_location) - # The chunk metadata is always 16 bytes long - chunk_metadata = fh.read(16) - header, relative_offset, data_length = struct.unpack("IIQ", chunk_metadata) - if header != 0xabeceda: - raise ValueError("The ND2 file seems to be corrupted.") - # We start at the location of the chunk metadata, skip over the metadata, and then proceed to the - # start of the actual data field, which is at some arbitrary place after the metadata. - fh.seek(chunk_location + 16 + relative_offset) - return fh.read(data_length) - - class V3Parser(BaseParser): """ Parses ND2 files and creates a Metadata and ImageReader object. """ CHUNK_HEADER = 0xabeceda diff --git a/setup.py b/setup.py index 1f246f4..d5feeaa 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,6 @@ from setuptools import setup -<<<<<<< HEAD VERSION = "1.1.2" -======= -VERSION = "1.1.1" ->>>>>>> origin/master setup( name="nd2reader",