# Path: exdir/core/mode.py
# def assert_file_open(file_object):
#     """
#     Decorator to check if the file is not closed.
#     """
#     if file_object.io_mode == OpenMode.FILE_CLOSED:
#         raise IOError("Unable to operate on closed File instance.")
# 
# class OpenMode(Enum):
#     READ_WRITE = 1
#     READ_ONLY = 2
#     FILE_CLOSED = 3
# 
# def assert_file_writable(file_object):
#     """
#     Decorator to check if the file is not closed,
#     and that it is not in read only mode.
#     """
#     if file_object.io_mode == OpenMode.FILE_CLOSED:
#         raise IOError("Unable to operate on closed File instance.")
#     if file_object.io_mode == OpenMode.READ_ONLY:
#         raise IOError("Cannot change data on file in read only 'r' mode")


from enum import Enum
from .mode import assert_file_open, OpenMode, assert_file_writable
import os
import numpy as np
import exdir
    import ruamel_yaml as yaml
    import ruamel.yaml as yaml
        -------
        The filename of the :code:`attributes.yaml` file.
        """
        assert_file_open(self.file)
        if self.mode == self._Mode.METADATA:
            return self.parent.meta_filename
        else:
            return self.parent.attributes_filename

    def __len__(self):
        return len(self.keys())

    def update(self, value):
        """
        Update the Attribute with the key/value pairs from :code:`value`, overwriting existing keys.

        This function accepts either another Attribute object, a dictionary object or an iterable of key/value pairs
        """
        for key in value:
            self[key] = value[key]

    def __str__(self):
        if self.file.io_mode == OpenMode.FILE_CLOSED:
            return "<Attributes of closed Exdir object>"
        string = ""
        for key in self:
            string += "{}: {},".format(key, self[key])
        return "Attribute({}, {{{}}})".format(self.parent.name, string)

    def _repr_html_(self):

# Path: exdir/core/mode.py
# def assert_file_open(file_object):
#     """
#     Decorator to check if the file is not closed.
#     """
#     if file_object.io_mode == OpenMode.FILE_CLOSED:
#         raise IOError("Unable to operate on closed File instance.")
# 
# class OpenMode(Enum):
#     READ_WRITE = 1
#     READ_ONLY = 2
#     FILE_CLOSED = 3
# 
# def assert_file_writable(file_object):
#     """
#     Decorator to check if the file is not closed,
#     and that it is not in read only mode.
#     """
#     if file_object.io_mode == OpenMode.FILE_CLOSED:
#         raise IOError("Unable to operate on closed File instance.")
#     if file_object.io_mode == OpenMode.READ_ONLY:
#         raise IOError("Cannot change data on file in read only 'r' mode")


# Path: exdir/core/attribute.py
from enum import Enum
from .mode import assert_file_open, OpenMode, assert_file_writable
import os
import numpy as np
import exdir
    import ruamel_yaml as yaml
    import ruamel.yaml as yaml

        -------
        The filename of the :code:`attributes.yaml` file.
        """
        assert_file_open(self.file)
        if self.mode == self._Mode.METADATA:
            return self.parent.meta_filename
        else:
            return self.parent.attributes_filename

    def __len__(self):
        return len(self.keys())

    def update(self, value):
        """
        Update the Attribute with the key/value pairs from :code:`value`, overwriting existing keys.

        This function accepts either another Attribute object, a dictionary object or an iterable of key/value pairs
        """
        for key in value:
            self[key] = value[key]

    def __str__(self):
        if self.file.io_mode == OpenMode.FILE_CLOSED:
            return "<Attributes of closed Exdir object>"
        string = ""
        for key in self:
            string += "{}: {},".format(key, self[key])
        return "Attribute({}, {{{}}})".format(self.parent.name, string)

    def _repr_html_(self):

        if self.file.io_mode == OpenMode.FILE_CLOSED: