Skip to content
Snippets Groups Projects
Verified Commit 39d40c84 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

REVERT: revert some unintended changes to high_level_api.py

parent a35313d0
No related branches found
No related tags found
No related merge requests found
Pipeline #41655 passed
...@@ -60,23 +60,23 @@ def standard_type_for_high_level_type(high_level_record: "CaosDBPythonEntity", ...@@ -60,23 +60,23 @@ def standard_type_for_high_level_type(high_level_record: "CaosDBPythonEntity",
class in the standard CaosDB API or - if return_string is True - return class in the standard CaosDB API or - if return_string is True - return
the role as a string. the role as a string.
""" """
if isinstance(high_level_record, CaosDBPythonRecord): if type(high_level_record) == CaosDBPythonRecord:
if not return_string: if not return_string:
return db.Record return db.Record
return "Record" return "Record"
elif isinstance(high_level_record, CaosDBPythonFile): elif type(high_level_record) == CaosDBPythonFile:
if not return_string: if not return_string:
return db.File return db.File
return "File" return "File"
elif isinstance(high_level_record, CaosDBPythonProperty): elif type(high_level_record) == CaosDBPythonProperty:
if not return_string: if not return_string:
return db.Property return db.Property
return "Property" return "Property"
elif isinstance(high_level_record, CaosDBPythonRecordType): elif type(high_level_record) == CaosDBPythonRecordType:
if not return_string: if not return_string:
return db.RecordType return db.RecordType
return "RecordType" return "RecordType"
elif isinstance(high_level_record, CaosDBPythonEntity): elif type(high_level_record) == CaosDBPythonEntity:
if not return_string: if not return_string:
return db.Entity return db.Entity
return "Entity" return "Entity"
...@@ -101,15 +101,15 @@ def high_level_type_for_standard_type(standard_record: db.Entity): ...@@ -101,15 +101,15 @@ def high_level_type_for_standard_type(standard_record: db.Entity):
if not isinstance(standard_record, db.Entity): if not isinstance(standard_record, db.Entity):
raise ValueError() raise ValueError()
role = standard_record.role role = standard_record.role
if role == "Record" or isinstance(standard_record, db.Record): if role == "Record" or type(standard_record) == db.Record:
return CaosDBPythonRecord return CaosDBPythonRecord
elif role == "File" or isinstance(standard_record, db.File): elif role == "File" or type(standard_record) == db.File:
return CaosDBPythonFile return CaosDBPythonFile
elif role == "Property" or isinstance(standard_record, db.Property): elif role == "Property" or type(standard_record) == db.Property:
return CaosDBPythonProperty return CaosDBPythonProperty
elif role == "RecordType" or isinstance(standard_record, db.RecordType): elif role == "RecordType" or type(standard_record) == db.RecordType:
return CaosDBPythonRecordType return CaosDBPythonRecordType
elif role == "Entity" or isinstance(standard_record, db.Entity): elif role == "Entity" or type(standard_record) == db.Entity:
return CaosDBPythonEntity return CaosDBPythonEntity
raise RuntimeError("Incompatible type.") raise RuntimeError("Incompatible type.")
...@@ -213,14 +213,14 @@ class CaosDBPythonEntity(object): ...@@ -213,14 +213,14 @@ class CaosDBPythonEntity(object):
""" """
Getter for the file. Getter for the file.
""" """
if not isinstance(self, CaosDBPythonFile): if type(self) != CaosDBPythonFile:
raise RuntimeError("Please don't use the file attribute for entities" raise RuntimeError("Please don't use the file attribute for entities"
" that are no files.") " that are no files.")
return self._file return self._file
@file.setter @file.setter
def file(self, val: str): def file(self, val: str):
if val is not None and not isinstance(self, CaosDBPythonFile): if val is not None and type(self) != CaosDBPythonFile:
raise RuntimeError("Please don't use the file attribute for entities" raise RuntimeError("Please don't use the file attribute for entities"
" that are no files.") " that are no files.")
self._file = val self._file = val
...@@ -230,14 +230,14 @@ class CaosDBPythonEntity(object): ...@@ -230,14 +230,14 @@ class CaosDBPythonEntity(object):
""" """
Getter for the path. Getter for the path.
""" """
if not isinstance(self, CaosDBPythonFile): if type(self) != CaosDBPythonFile:
raise RuntimeError("Please don't use the path attribute for entities" raise RuntimeError("Please don't use the path attribute for entities"
" that are no files.") " that are no files.")
return self._path return self._path
@path.setter @path.setter
def path(self, val: str): def path(self, val: str):
if val is not None and not isinstance(self, CaosDBPythonFile): if val is not None and type(self) != CaosDBPythonFile:
raise RuntimeError("Please don't use the path attribute for entities" raise RuntimeError("Please don't use the path attribute for entities"
" that are no files.") " that are no files.")
self._path = val self._path = val
...@@ -651,7 +651,7 @@ class CaosDBPythonEntity(object): ...@@ -651,7 +651,7 @@ class CaosDBPythonEntity(object):
if baseprop in serialization: if baseprop in serialization:
entity.__setattr__(baseprop, serialization[baseprop]) entity.__setattr__(baseprop, serialization[baseprop])
if isinstance(entity, CaosDBPythonFile): if type(entity) == CaosDBPythonFile:
entity.file = serialization["file"] entity.file = serialization["file"]
entity.path = serialization["path"] entity.path = serialization["path"]
...@@ -725,7 +725,7 @@ class CaosDBPythonEntity(object): ...@@ -725,7 +725,7 @@ class CaosDBPythonEntity(object):
val = str(val) val = str(val)
fulldict[baseprop] = val fulldict[baseprop] = val
if isinstance(self, CaosDBPythonFile): if type(self) == CaosDBPythonFile:
fulldict["file"] = self.file fulldict["file"] = self.file
fulldict["path"] = self.path fulldict["path"] = self.path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment