mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
Track last actions and friendlier error reporting when something breaks
This commit is contained in:
@@ -72,6 +72,8 @@ class Facet:
|
||||
def __init__(self, *parameters):
|
||||
self.status = None
|
||||
self.failures: list[FacetFailure] = []
|
||||
self.parameters = []
|
||||
self.applicability_templates = []
|
||||
for i, name in enumerate(self.parameters):
|
||||
setattr(self, name.replace("@", ""), parameters[i])
|
||||
|
||||
@@ -101,8 +103,10 @@ class Facet:
|
||||
return self
|
||||
|
||||
def filter(
|
||||
self, ifc_file: ifcopenshell.file, elements: list[ifcopenshell.entity_instance]
|
||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
if not elements:
|
||||
return []
|
||||
return [e for e in elements if self(e)]
|
||||
|
||||
def to_string(
|
||||
@@ -133,6 +137,7 @@ class Facet:
|
||||
total_replacements += 1
|
||||
if total_replacements == total_variables:
|
||||
return template
|
||||
return "This facet cannot be interpreted"
|
||||
|
||||
def to_ids_value(self, parameter: Union[str, Restriction, list]) -> dict[str, Any]:
|
||||
if isinstance(parameter, str):
|
||||
|
||||
@@ -75,8 +75,8 @@ class Ids:
|
||||
milestone=None,
|
||||
):
|
||||
# Not part of the IDS spec, but very useful in practice
|
||||
self.filepath = None
|
||||
self.filename = None
|
||||
self.filepath: Optional[str] = None
|
||||
self.filename: Optional[str] = None
|
||||
|
||||
self.specifications: List[Specification] = []
|
||||
self.info = {}
|
||||
@@ -300,6 +300,7 @@ class Specification:
|
||||
return "optional"
|
||||
elif self.maxOccurs == 0:
|
||||
return "prohibited"
|
||||
return "required" # Fallback
|
||||
|
||||
def set_usage(self, usage: Cardinality) -> None:
|
||||
if usage == "optional":
|
||||
|
||||
Reference in New Issue
Block a user