Skip to content
Snippets Groups Projects

Filling XLSX: Everything except multiple choice.

Merged Daniel Hornung requested to merge f-json-table into dev
All threads resolved!
Compare and Show latest version
26 files
+ 353
101
Compare changes
  • Side-by-side
  • Inline
Files
26
#!/usr/bin/env python3
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead Project.
#
# Copyright (C) 2020,2021 IndiScale GmbH <www.indiscale.com>
# Copyright (C) 2020 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020-2025 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2021 Henrik tom Wörden <h.tomwoerden@indiscale.com>
# Copyright (C) 2021 Alexander Kreft
# Copyright (C) 2021 Laboratory for Fluid Physics and Biocomplexity,
@@ -33,19 +33,14 @@ attributes. Groups and datasets are mapped to Records and attributes to
Properties.
"""
import re
from copy import deepcopy
import caosdb as db
import h5py
import numpy as np
from caosadvancedtools.cfood import fileguide
from caosdb.common.datatype import is_reference
from caosdb.common.utils import uuid
from ..cfood import (AbstractFileCFood, assure_has_description,
assure_has_parent, assure_has_property,
assure_property_is)
from ..cfood import AbstractFileCFood
from ..structure_mapping import (EntityMapping, collect_existing_structure,
update_structure)
@@ -100,8 +95,7 @@ def h5_attr_to_property(val):
if hasattr(val, 'ndim'):
if not isinstance(val, np.ndarray) and val.ndim != 0:
print(val, val.ndim)
raise Exception(
"Implementation assumes that only np.arrays have ndim.")
raise RuntimeError("Implementation assumes that only np.arrays have ndim.")
return val, dtype
@@ -127,6 +121,8 @@ class H5CFood(AbstractFileCFood):
self.identifiable_root = None
self.root_name = "root"
self.hdf5Container = db.Container()
self.to_be_inserted = db.Container()
self.structure = db.Container()
self.em = EntityMapping()
def collect_information(self):
@@ -165,7 +161,8 @@ class H5CFood(AbstractFileCFood):
"""
self.structure._cuid = "root element"
# TODO Why do we need a protected member here?
self.structure._cuid = "root element" # pylint: disable=protected-access
self.em.add(self.structure, self.identifiable_root)
collect_existing_structure(self.structure, self.identifiable_root,
self.em)
@@ -282,7 +279,7 @@ class H5CFood(AbstractFileCFood):
return rec
def insert_missing_structure(self, target_structure: db.Record):
if target_structure._cuid not in self.em.to_existing:
if target_structure._cuid not in self.em.to_existing: # pylint: disable=protected-access
self.to_be_inserted.append(target_structure)
for prop in target_structure.get_properties():
Loading