Skip to content
Snippets Groups Projects

F refactor high level api

Merged Alexander Schlemmer requested to merge f-refactor-high-level-api into dev
2 files
+ 34
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -78,6 +78,20 @@ def standard_type_for_high_level_type(high_level_record: "CaosDBPythonEntity",
raise RuntimeError("Incompatible type.")
def high_level_type_for_role(role: str):
if role == "Record":
return CaosDBPythonRecord
if role == "File":
return CaosDBPythonFile
if role == "Property":
return CaosDBPythonProperty
if role == "RecordType":
return CaosDBPythonRecordType
if role == "Entity":
return CaosDBPythonEntity
raise RuntimeError("Unknown role.")
def high_level_type_for_standard_type(standard_record: db.Entity):
if type(standard_record) == db.Record:
return CaosDBPythonRecord
@@ -586,8 +600,13 @@ class CaosDBPythonEntity(object):
return [p for p in self.__dict__
if p not in self._forbidden]
def deserialize(self, serialization: dict):
raise NotImplementedError()
@staticmethod
def deserialize(serialization: dict):
"""
Deserialize a yaml representation of an entity in high level API form.
"""
pass
def serialize(self, without_metadata: bool = False):
"""
@@ -605,7 +624,7 @@ class CaosDBPythonEntity(object):
fulldict = dict()
# Add CaosDB role:
fulldict["role"] = standard_type_for_high_level_type(self, True)
for parent in self._parents:
if isinstance(parent, CaosDBPythonEntity):
Loading