mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
hasattr to isinstance()
This commit is contained in:
committed by
Thomas Krijnen
parent
d00c3735ec
commit
2b522b71cb
@@ -601,9 +601,9 @@ def to_string_header_entity(header_entity):
|
|||||||
"""Recreate IFC header string representation, like FILE_NAME(...)"""
|
"""Recreate IFC header string representation, like FILE_NAME(...)"""
|
||||||
|
|
||||||
# Prefer native .toString() if available (native IfcOpenShell wrapper)
|
# Prefer native .toString() if available (native IfcOpenShell wrapper)
|
||||||
if hasattr(header_entity, 'toString'):
|
if isinstance(header_entity, W.HeaderEntity):
|
||||||
return header_entity.toString()
|
return header_entity.toString()
|
||||||
elif hasattr(header_entity, '_fields'):
|
elif isinstance(header_entity, tuple):
|
||||||
values = [repr(getattr(header_entity, f)) for f in header_entity._fields]
|
values = [repr(getattr(header_entity, f)) for f in header_entity._fields]
|
||||||
return f"{type(header_entity).__name__.upper()}({','.join(values)})"
|
return f"{type(header_entity).__name__.upper()}({','.join(values)})"
|
||||||
else:
|
else:
|
||||||
@@ -614,7 +614,7 @@ def validate_ifc_header(f: Union[ifcopenshell.file, ifcopenshell.simple_spf.file
|
|||||||
AGGREGATE_TYPE = "LIST [ 1 : ? ] OF STRING (256)"
|
AGGREGATE_TYPE = "LIST [ 1 : ? ] OF STRING (256)"
|
||||||
STRING_TYPE = "STRING (256)"
|
STRING_TYPE = "STRING (256)"
|
||||||
|
|
||||||
def log_error(header_entity: W.HeaderEntity, name: str, index: int, expected_type: str, provided_type: str) -> None:
|
def log_error(header_entity: Union[W.HeaderEntity, tuple], name: str, index: int, expected_type: str, provided_type: str) -> None:
|
||||||
logger.error(
|
logger.error(
|
||||||
(
|
(
|
||||||
"For instance:\n %s\n %s\n"
|
"For instance:\n %s\n %s\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user