# 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)
# 
# Path: pyfive/core.py
# 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))
# 
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


import struct
from collections import OrderedDict
from .core import _padded_size, _structure_size
from .core import _unpack_struct_from, _unpack_struct_from_file
from .core import InvalidHDF5File
        self._contents = node

    def assign_name(self, heap):
        """ Assign link names to all entries in the symbol table. """
        for entry in self.entries:
            offset = entry['link_name_offset']
            link_name = heap.get_object_name(offset).decode('utf-8')
            entry['link_name'] = link_name
        return

    def get_links(self, heap):
        """ Return a dictionary of links (dataset/group) and offsets. """
        links = {}
        for e in self.entries:
            if e['cache_type'] in [0,1]:
                links[e['link_name']] = e['object_header_address']
            elif e['cache_type'] == 2:
                offset = struct.unpack('<4I', e['scratch'])[0]
                links[e['link_name']] = heap.get_object_name(offset).decode('utf-8')
        return links


class GlobalHeap(object):
    """
    HDF5 Global Heap collection.
    """

    def __init__(self, fh, offset):

        fh.seek(offset)

# 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)
# 
# Path: pyfive/core.py
# 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))
# 
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class InvalidHDF5File(Exception):
#     """ Exception raised when an invalid HDF5 file is detected. """
#     pass


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

        self._contents = node

    def assign_name(self, heap):
        """ Assign link names to all entries in the symbol table. """
        for entry in self.entries:
            offset = entry['link_name_offset']
            link_name = heap.get_object_name(offset).decode('utf-8')
            entry['link_name'] = link_name
        return

    def get_links(self, heap):
        """ Return a dictionary of links (dataset/group) and offsets. """
        links = {}
        for e in self.entries:
            if e['cache_type'] in [0,1]:
                links[e['link_name']] = e['object_header_address']
            elif e['cache_type'] == 2:
                offset = struct.unpack('<4I', e['scratch'])[0]
                links[e['link_name']] = heap.get_object_name(offset).decode('utf-8')
        return links


class GlobalHeap(object):
    """
    HDF5 Global Heap collection.
    """

    def __init__(self, fh, offset):

        fh.seek(offset)

        header = _unpack_struct_from_file(GLOBAL_HEAP_HEADER, fh)