From 274a5cbfad65474564fa256a8f37a7a2488f3a0f Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 4 Sep 2025 18:53:27 +0500 Subject: [PATCH] sql, stream - provide `schema_identifier` to avoid errors --- src/ifcopenshell-python/ifcopenshell/sql.py | 13 ++++++++++--- src/ifcopenshell-python/ifcopenshell/stream.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index f73bb11cff..6b757f4f5b 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -37,8 +37,6 @@ except ImportError as e: class sqlite(file): - schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4" - def __init__(self, filepath: str): """ Open existing sqlite IFC database. @@ -81,7 +79,7 @@ class sqlite(file): except: assert False, "SQLite schema not supported." - self.schema = row[1] + self._schema = row[1] self.ifc_schema = ifcopenshell.schema_by_name(self.schema) self.cursor.execute("SELECT ifc_id, ifc_class FROM id_map") @@ -272,6 +270,15 @@ class sqlite(file): # Override to avoid clean up data unrelated to sqlite file. pass + @property + def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA: + return self._schema + + @property + def schema_identifier(self) -> str: + # The best option we've got for mimicing `file.schema_identifier`. + return self._schema + class sqlite_entity(entity_instance): sqlite_wrapper: sqlite_wrapper diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index 999fd4abea..8e715bac66 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -87,8 +87,6 @@ try: return (int(items[0]), str(items[1]), items[2]) class stream(file): - schema: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4" - def __init__(self, filepath: str): self.wrapped_data = None self.history_size = 64 @@ -176,7 +174,7 @@ try: self.class_map.setdefault(ifc_class, []).append(step_id) self.id_offset[step_id] = offset elif line.startswith("FILE_SCHEMA"): - self.schema = line.split("'")[1] + self._schema = line.split("'")[1] self.ifc_schema = ifcopenshell.schema_by_name(self.schema) for ifc_class in exclude_classes: declaration = self.ifc_schema.declaration_by_name(ifc_class) @@ -290,6 +288,15 @@ try: # Override to avoid clean up unrelated to stream file. pass + @property + def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA: + return self._schema + + @property + def schema_identifier(self) -> str: + # The best option we've got for mimicing `file.schema_identifier`. + return self._schema + class stream_entity(entity_instance): stream_wrapper: stream_wrapper