From 309ce20068e1eb18a2578b07689af71f989993c7 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 15 Jul 2022 14:38:57 +1000 Subject: [PATCH] Added error sentences for IDS property facet results --- src/ifctester/ifctester/__main__.py | 3 +-- src/ifctester/ifctester/facet.py | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/ifctester/ifctester/__main__.py b/src/ifctester/ifctester/__main__.py index 8409d44080..bde6e103fa 100644 --- a/src/ifctester/ifctester/__main__.py +++ b/src/ifctester/ifctester/__main__.py @@ -20,10 +20,9 @@ import time import argparse - +import ifcopenshell from . import ids from . import reporter -import ifcopenshell parser = argparse.ArgumentParser(description="Uses an IDS to audit an IFC") parser.add_argument("ids", type=str, help="Path to an IDS") diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 22d65e694b..658a109f13 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -351,6 +351,10 @@ class Property(Facet): psets = {k: v for k, v in all_psets.items() if k == self.propertySet} is_pass = bool(psets) + reason = None + + if not is_pass: + reason = {"type": "NOPSET"} if is_pass: props = {} @@ -365,6 +369,7 @@ class Property(Facet): if not bool(props[pset_name]): is_pass = False + reason = {"type": "NOVALUE"} break if self.measure: @@ -381,6 +386,7 @@ class Property(Facet): if data_type != self.measure: is_pass = False + reason = {"type": "MEASURE", "actual": data_type} break unit = ifcopenshell.util.unit.get_property_unit(prop_entity, inst.wrapped_data.file) @@ -399,8 +405,9 @@ class Property(Facet): if self.value: if any([v != self.value for v in props[pset_name].values()]): is_pass = False + reason = {"type": "VALUE", "actual": list(props[pset_name].values())} break - return PropertyResult(is_pass, "todo") + return PropertyResult(is_pass, reason) class Material(Facet): @@ -625,8 +632,6 @@ class ClassificationResult(Result): def to_string(self): if self.reason["type"] == "NOVALUE": return "The entity has no classification" - elif self.reason["type"] == "VALUE": - return f"The found references \"{str(self.reason['actual'])}\" do not match the requirements" elif self.reason["type"] == "VALUE": return f"The references \"{str(self.reason['actual'])}\" do not match the requirements" elif self.reason["type"] == "system": @@ -640,7 +645,16 @@ class PartOfResult(Result): class PropertyResult(Result): def to_string(self): - return "TODO" + if self.reason["type"] == "NOPSET": + return "The entity has no property sets" + elif self.reason["type"] == "NOVALUE": + return "The property set does not contain the required property" + elif self.reason["type"] == "MEASURE": + return f"The data type \"{str(self.reason['actual'])}\" does not match the requirements" + elif self.reason["type"] == "VALUE" and len(self.reason['actual']) == 1: + return f"The property value \"{str(self.reason['actual'][0])}\" does not match the requirements" + elif self.reason["type"] == "VALUE": + return f"The property values \"{str(self.reason['actual'])}\" do not match the requirements" class MaterialResult(Result):