ifcopenshell.file - add todo notes for temp workarounds, make workaround more explicit

This commit is contained in:
Andrej730
2025-11-04 18:55:48 +05:00
parent a50c8869a5
commit aeed371888
+9 -4
View File
@@ -25,6 +25,7 @@ import zipfile
import functools import functools
import ifcopenshell import ifcopenshell
import weakref import weakref
import types
from pathlib import Path from pathlib import Path
from typing import Any, Optional, TYPE_CHECKING, Union, overload, Literal, TypedDict from typing import Any, Optional, TYPE_CHECKING, Union, overload, Literal, TypedDict
from collections.abc import Callable, Generator from collections.abc import Callable, Generator
@@ -248,6 +249,8 @@ READ_ERROR = ifcopenshell_wrapper.file_open_status.READ_ERROR
NO_HEADER = ifcopenshell_wrapper.file_open_status.NO_HEADER NO_HEADER = ifcopenshell_wrapper.file_open_status.NO_HEADER
UNSUPPORTED_SCHEMA = ifcopenshell_wrapper.file_open_status.UNSUPPORTED_SCHEMA UNSUPPORTED_SCHEMA = ifcopenshell_wrapper.file_open_status.UNSUPPORTED_SCHEMA
INVALID_SYNTAX = ifcopenshell_wrapper.file_open_status.INVALID_SYNTAX INVALID_SYNTAX = ifcopenshell_wrapper.file_open_status.INVALID_SYNTAX
# TODO: Workaround for old builds, remove after build stabilizes.
try: try:
UNKNOWN = ifcopenshell_wrapper.file_open_status.UNKNOWN UNKNOWN = ifcopenshell_wrapper.file_open_status.UNKNOWN
except: except:
@@ -535,7 +538,6 @@ class file:
""" """
wrapped_data: ifcopenshell_wrapper.file wrapped_data: ifcopenshell_wrapper.file
header: file_header
units: dict[str, entity_instance] = {} units: dict[str, entity_instance] = {}
history_size: int = 64 history_size: int = 64
history: list[Transaction] history: list[Transaction]
@@ -1049,10 +1051,13 @@ class file:
return self.wrapped_data.to_string() return self.wrapped_data.to_string()
@property @property
def header(self): def header(self) -> file_header:
try: # TODO: Workaround for old builds, remove after build stabilizes.
# TODO: No need for `wrapped_data.header` to be a method - should use `@property`?
header = self.wrapped_data.header
if isinstance(header, types.MethodType):
return file_header(self, self.wrapped_data.header()) return file_header(self, self.wrapped_data.header())
except: else:
return self.wrapped_data.header return self.wrapped_data.header
@property @property