Browse Source

#66 fixed import problems

zolfa-add_slices_loading
jim 9 years ago
parent
commit
4ec54183d1
3 changed files with 16 additions and 17 deletions
  1. +11
    -0
      nd2reader/parser/base.py
  2. +0
    -11
      nd2reader/parser/parser.py
  3. +5
    -6
      nd2reader/parser/v3.py

+ 11
- 0
nd2reader/parser/base.py View File

@ -0,0 +1,11 @@
from abc import abstractproperty
class BaseParser(object):
@abstractproperty
def metadata(self):
raise NotImplementedError
@abstractproperty
def driver(self):
raise NotImplementedError

+ 0
- 11
nd2reader/parser/parser.py View File

@ -1,6 +1,5 @@
from nd2reader.parser.v3 import V3Parser
from nd2reader.exc import InvalidVersionError
from abc import abstractproperty
def get_parser(filename, major_version, minor_version):
@ -9,13 +8,3 @@ def get_parser(filename, major_version, minor_version):
if not parser:
raise InvalidVersionError("No parser is available for that version.")
return parser(filename)
class BaseParser(object):
@abstractproperty
def metadata(self):
raise NotImplementedError
@abstractproperty
def driver(self):
raise NotImplementedError

+ 5
- 6
nd2reader/parser/v3.py View File

@ -3,7 +3,7 @@
import array
from datetime import datetime
from nd2reader.model.metadata import Metadata
from nd2reader.parser.parser import BaseParser
from nd2reader.parser.base import BaseParser
import re
import six
import struct
@ -24,7 +24,7 @@ class V3Parser(BaseParser):
def metadata(self):
if not self._metadata:
self._parse_metadata()
return self.metadata
return self._metadata
@property
def driver(self):
@ -207,6 +207,8 @@ class V3Parser(BaseParser):
"""
Gets the data for a given chunk pointer
:rtype: bytes
"""
self._get_file_handle().seek(chunk_location)
# The chunk metadata is always 16 bytes long
@ -217,10 +219,7 @@ class V3Parser(BaseParser):
# 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.
self._get_file_handle().seek(chunk_location + 16 + relative_offset)
val = self._get_file_handle().read(data_length)
print("**************************")
print(type(val))
return val
return self._get_file_handle().read(data_length)
def _parse_unsigned_char(self, data):
return struct.unpack("B", data.read(1))[0]


Loading…
Cancel
Save