diff --git a/src/caosdb/high_level_api.py b/src/caosdb/high_level_api.py index 87ff7c5fec6ac670b112e019fc04232f431745da..427a095a4bafc0c372b0169298f2980dbd902c49 100644 --- a/src/caosdb/high_level_api.py +++ b/src/caosdb/high_level_api.py @@ -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 the role as a string. """ - if isinstance(high_level_record, CaosDBPythonRecord): + if type(high_level_record) == CaosDBPythonRecord: if not return_string: return db.Record return "Record" - elif isinstance(high_level_record, CaosDBPythonFile): + elif type(high_level_record) == CaosDBPythonFile: if not return_string: return db.File return "File" - elif isinstance(high_level_record, CaosDBPythonProperty): + elif type(high_level_record) == CaosDBPythonProperty: if not return_string: return db.Property return "Property" - elif isinstance(high_level_record, CaosDBPythonRecordType): + elif type(high_level_record) == CaosDBPythonRecordType: if not return_string: return db.RecordType return "RecordType" - elif isinstance(high_level_record, CaosDBPythonEntity): + elif type(high_level_record) == CaosDBPythonEntity: if not return_string: return db.Entity return "Entity" @@ -101,15 +101,15 @@ def high_level_type_for_standard_type(standard_record: db.Entity): if not isinstance(standard_record, db.Entity): raise ValueError() role = standard_record.role - if role == "Record" or isinstance(standard_record, db.Record): + if role == "Record" or type(standard_record) == db.Record: return CaosDBPythonRecord - elif role == "File" or isinstance(standard_record, db.File): + elif role == "File" or type(standard_record) == db.File: return CaosDBPythonFile - elif role == "Property" or isinstance(standard_record, db.Property): + elif role == "Property" or type(standard_record) == db.Property: return CaosDBPythonProperty - elif role == "RecordType" or isinstance(standard_record, db.RecordType): + elif role == "RecordType" or type(standard_record) == db.RecordType: return CaosDBPythonRecordType - elif role == "Entity" or isinstance(standard_record, db.Entity): + elif role == "Entity" or type(standard_record) == db.Entity: return CaosDBPythonEntity raise RuntimeError("Incompatible type.") @@ -213,14 +213,14 @@ class CaosDBPythonEntity(object): """ Getter for the file. """ - if not isinstance(self, CaosDBPythonFile): + if type(self) != CaosDBPythonFile: raise RuntimeError("Please don't use the file attribute for entities" " that are no files.") return self._file @file.setter 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" " that are no files.") self._file = val @@ -230,14 +230,14 @@ class CaosDBPythonEntity(object): """ Getter for the path. """ - if not isinstance(self, CaosDBPythonFile): + if type(self) != CaosDBPythonFile: raise RuntimeError("Please don't use the path attribute for entities" " that are no files.") return self._path @path.setter 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" " that are no files.") self._path = val @@ -646,7 +646,7 @@ class CaosDBPythonEntity(object): if baseprop in serialization: entity.__setattr__(baseprop, serialization[baseprop]) - if isinstance(entity, CaosDBPythonFile): + if type(entity) == CaosDBPythonFile: entity.file = serialization["file"] entity.path = serialization["path"] @@ -717,7 +717,7 @@ class CaosDBPythonEntity(object): if val is not None: fulldict[baseprop] = val - if isinstance(self, CaosDBPythonFile): + if type(self) == CaosDBPythonFile: fulldict["file"] = self.file fulldict["path"] = self.path