# Path: core/ezdxf/lldxf/const.py
# class DXFStructureError(DXFError):
#     pass


from .lldxf.const import DXFStructureError
    def __iter__(self):
        """ Iterate over all layout entity spaces.
        """
        return iter(self._layout_spaces.values())

    def __getitem__(self, key):
        """ Get layout entity space by *key*.
        """
        return self._layout_spaces[key]

    def __len__(self):
        return sum(len(entity_space) for entity_space in self._layout_spaces.values())

    def handles(self):
        """ Iterate over all handles in all entity spaces.
        """
        for entity_space in self:
            for handle in entity_space:
                yield handle

    def repair_model_space(self, new_model_space_key):
        def update_entity_tags(entity_space):
            for handle in entity_space:
                tags = entity_space.get_tags_by_handle(handle)
                tags.noclass.set_first(330, new_model_space_key)

                # if paper space is set to 1 -> set 0 for model space
                try:
                    entity_tags = tags.get_subclass("AcDbEntity")
                except KeyError:

# Path: core/ezdxf/lldxf/const.py
# class DXFStructureError(DXFError):
#     pass


# Path: core/ezdxf/entityspace.py
from .lldxf.const import DXFStructureError

    def __iter__(self):
        """ Iterate over all layout entity spaces.
        """
        return iter(self._layout_spaces.values())

    def __getitem__(self, key):
        """ Get layout entity space by *key*.
        """
        return self._layout_spaces[key]

    def __len__(self):
        return sum(len(entity_space) for entity_space in self._layout_spaces.values())

    def handles(self):
        """ Iterate over all handles in all entity spaces.
        """
        for entity_space in self:
            for handle in entity_space:
                yield handle

    def repair_model_space(self, new_model_space_key):
        def update_entity_tags(entity_space):
            for handle in entity_space:
                tags = entity_space.get_tags_by_handle(handle)
                tags.noclass.set_first(330, new_model_space_key)

                # if paper space is set to 1 -> set 0 for model space
                try:
                    entity_tags = tags.get_subclass("AcDbEntity")
                except KeyError:

                    raise DXFStructureError("Entity has no subclass 'AcDbEntity'.")