# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# def _structure_size(structure):
#     """ Return the size of a structure in bytes. """
#     fmt = '<' + ''.join(structure.values())
#     return struct.calcsize(fmt)
# 
# def _unpack_struct_from(structure, buf, offset=0):
#     """ Unpack a structure into an OrderedDict from a buffer of bytes. """
#     fmt = '<' + ''.join(structure.values())
#     values = struct.unpack_from(fmt, buf, offset=offset)
#     return OrderedDict(zip(structure.keys(), values))
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


from collections import OrderedDict
from .core import _padded_size, _structure_size, _unpack_struct_from
from .core import InvalidHDF5File
""" Representation and reading of HDF5 datatype messages. """




class DatatypeMessage(object):
    """ Representation of a HDF5 Datatype Message. """
    # Contents and layout defined in IV.A.2.d.

    def __init__(self, buf, offset):
        self.buf = buf
        self.offset = offset
        self.dtype = self.determine_dtype()

    def determine_dtype(self):
        """ Return the dtype (often numpy-like) for the datatype message.  """

# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# def _structure_size(structure):
#     """ Return the size of a structure in bytes. """
#     fmt = '<' + ''.join(structure.values())
#     return struct.calcsize(fmt)
# 
# def _unpack_struct_from(structure, buf, offset=0):
#     """ Unpack a structure into an OrderedDict from a buffer of bytes. """
#     fmt = '<' + ''.join(structure.values())
#     values = struct.unpack_from(fmt, buf, offset=offset)
#     return OrderedDict(zip(structure.keys(), values))
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


# Path: pyfive/datatype_msg.py
from collections import OrderedDict
from .core import _padded_size, _structure_size, _unpack_struct_from
from .core import InvalidHDF5File

""" Representation and reading of HDF5 datatype messages. """




class DatatypeMessage(object):
    """ Representation of a HDF5 Datatype Message. """
    # Contents and layout defined in IV.A.2.d.

    def __init__(self, buf, offset):
        self.buf = buf
        self.offset = offset
        self.dtype = self.determine_dtype()

    def determine_dtype(self):
        """ Return the dtype (often numpy-like) for the datatype message.  """

        datatype_msg = _unpack_struct_from(DATATYPE_MSG, self.buf, self.offset)