Skip to content
Snippets Groups Projects
Commit 93b66da6 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

MAINT(structure-elements): moved the ROCrateEntity structure element to separate package

parent 70c90491
No related branches found
No related tags found
2 merge requests!198REL: Release 0.10.0,!193ROCrate-Converter (also for .eln-files)
Pipeline #57346 failed
...@@ -20,4 +20,12 @@ ...@@ -20,4 +20,12 @@
"""Submdule containing all default and optional converters.""" """Submdule containing all default and optional converters."""
from .. import utils
from .structure_elements import * from .structure_elements import *
try:
from .rocrate_structure_elements import ROCrateEntity
except ImportError as err:
ROCrateEntity: type = utils.MissingImport(
name="ROCrateEntity", hint="Try installing with the `rocrate` extra option.",
err=err)
#!/usr/bin/env python3
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2024 Alexander Schlemmer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
#
from rocrate.model.entity import Entity
from .structure_elements import StructureElement
class ROCrateEntity(StructureElement):
"""
Store entities contained in ROCrates.
"""
def __init__(self, folder: str, entity: Entity):
"""
Initializes this ROCrateEntity.
Arguments:
----------
folder: str
The folder that contains the ROCrate data. In case of a zipped ROCrate, this
is a temporary folder that the ROCrate was unzipped to.
The folder is the folder containing the ro-crate-metadata.json.
entity: Entity
The ROCrate entity that is stored in this structure element.
The entity automatically contains an attribute ".crate"
that stores the ROCrate that this entity belongs to. It can be used
e.g. to look up links to other entities (ROCrate.dereference).
"""
super().__init__(entity.properties()["@id"])
self.folder = folder
self.entity = entity
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
import warnings import warnings
import lxml.etree import lxml.etree
from rocrate.model.entity import Entity
class StructureElement(object): class StructureElement(object):
...@@ -219,31 +218,3 @@ class XMLAttributeNode(StructureElement): ...@@ -219,31 +218,3 @@ class XMLAttributeNode(StructureElement):
self.value = element.attrib[key] self.value = element.attrib[key]
self.key = key self.key = key
self.tag = element self.tag = element
class ROCrateEntity(StructureElement):
"""
Store entities contained in ROCrates.
"""
def __init__(self, folder: str, entity: Entity):
"""
Initializes this ROCrateEntity.
Arguments:
----------
folder: str
The folder that contains the ROCrate data. In case of a zipped ROCrate, this
is a temporary folder that the ROCrate was unzipped to.
The folder is the folder containing the ro-crate-metadata.json.
entity: Entity
The ROCrate entity that is stored in this structure element.
The entity automatically contains an attribute ".crate"
that stores the ROCrate that this entity belongs to. It can be used
e.g. to look up links to other entities (ROCrate.dereference).
"""
super().__init__(entity.properties()["@id"])
self.folder = folder
self.entity = entity
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment