From 54fdec5e08cc48c69b05accd28be91d7670e20e9 Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Sun, 12 May 2024 17:47:18 +0200 Subject: [PATCH] implicit schema when looking up csv pset --- ...rties-and-property-sets-validation.feature | 62 ++++--------------- .../pset_definitions.csv} | 0 .../pset_definitions.csv} | 0 .../pset_definitions.csv} | 0 features/steps/thens/relations.py | 16 ++++- 5 files changed, 25 insertions(+), 53 deletions(-) rename features/resources/{property_set_definitions/IFC2x3_definitions.csv => IFC2X3/pset_definitions.csv} (100%) rename features/resources/{property_set_definitions/IFC4_definitions.csv => IFC4/pset_definitions.csv} (100%) rename features/resources/{property_set_definitions/IFC4X3_definitions.csv => IFC4X3/pset_definitions.csv} (100%) diff --git a/features/PSE001_Standard-properties-and-property-sets-validation.feature b/features/PSE001_Standard-properties-and-property-sets-validation.feature index 4cd2a00a..e7a8aa5b 100644 --- a/features/PSE001_Standard-properties-and-property-sets-validation.feature +++ b/features/PSE001_Standard-properties-and-property-sets-validation.feature @@ -9,66 +9,28 @@ The rule verifies that each IfcPropertySet starting with Pset is defined correct Given An IfcPropertySet Given its Name attribute starts with Pset - Scenario Outline: IfcPropertySet Name - - Given a file with Schema "" - Then The IfcPropertySet Name attribute value must use predefined values according to the "" table - - Examples: - | schema | csv_table | - | IFC2X3 | IFC2x3_definitions.csv | - | IFC4 | IFC4_definitions.csv | - | IFC4X3 | IFC4X3_definitions.csv | - - - Scenario Outline: Property Name - - Given a file with Schema "" + Scenario: IfcPropertySet Name + + Then The IfcPropertySet Name attribute value must use predefined values according to the "pset_definitions" table - Then Each associated IfcProperty must be named according to the property set definitions table "" - Examples: - | schema | csv_table | - | IFC2X3 | IFC2x3_definitions.csv | - | IFC4 | IFC4_definitions.csv | - | IFC4X3 | IFC4X3_definitions.csv | + Scenario: Property Name - - Scenario Outline: PropertySet definitions + Then Each associated IfcProperty must be named according to the property set definitions table "pset_definitions" - Given a file with Schema "" - Then The IfcPropertySet must be assigned according to the property set definitions table "" + Scenario: PropertySet definitions - Examples: - | schema | csv_table | - | IFC2X3 | IFC2x3_definitions.csv | - | IFC4 | IFC4_definitions.csv | - | IFC4X3 | IFC4X3_definitions.csv | + Then The IfcPropertySet must be assigned according to the property set definitions table "pset_definitions" - Scenario Outline: Property Type + Scenario: Property Type - Given a file with Schema "" + Then Each associated IfcProperty must be of type according to the property set definitions table "pset_definitions" - Then Each associated IfcProperty must be of type according to the property set definitions table "" + + Scenario: Property Data Type - Examples: - | schema | csv_table | - | IFC2X3 | IFC2x3_definitions.csv | - | IFC4 | IFC4_definitions.csv | - | IFC4X3 | IFC4X3_definitions.csv | + Then Each associated IfcProperty value must be of data type according to the property set definitions table "pset_definitions" - - Scenario Outline: Property Data Type - - Given a file with Schema "" - - Then Each associated IfcProperty value must be of data type according to the property set definitions table "" - - Examples: - | schema | csv_table | - | IFC2X3 | IFC2x3_definitions.csv | - | IFC4 | IFC4_definitions.csv | - | IFC4X3 | IFC4X3_definitions.csv | diff --git a/features/resources/property_set_definitions/IFC2x3_definitions.csv b/features/resources/IFC2X3/pset_definitions.csv similarity index 100% rename from features/resources/property_set_definitions/IFC2x3_definitions.csv rename to features/resources/IFC2X3/pset_definitions.csv diff --git a/features/resources/property_set_definitions/IFC4_definitions.csv b/features/resources/IFC4/pset_definitions.csv similarity index 100% rename from features/resources/property_set_definitions/IFC4_definitions.csv rename to features/resources/IFC4/pset_definitions.csv diff --git a/features/resources/property_set_definitions/IFC4X3_definitions.csv b/features/resources/IFC4X3/pset_definitions.csv similarity index 100% rename from features/resources/property_set_definitions/IFC4X3_definitions.csv rename to features/resources/IFC4X3/pset_definitions.csv diff --git a/features/steps/thens/relations.py b/features/steps/thens/relations.py index ce70648c..fefa79f8 100644 --- a/features/steps/thens/relations.py +++ b/features/steps/thens/relations.py @@ -3,6 +3,7 @@ import operator from validation_handling import gherkin_ifc import json +import os from utils import ifc, misc, system @@ -184,6 +185,17 @@ def upper_case_if_string(v): return v.upper() except: return v + +def get_pset_definitions(context, table): + schema_specific_path = system.get_abs_path(f"resources/{context.model.schema.upper()}/{table}.csv") + + if os.path.exists(schema_specific_path): + tbl_path = schema_specific_path + else: + tbl_path =system.get_abs_path(f"resources/{table}.csv") + + tbl = system.get_csv(tbl_path, return_type='dict') + return {d['property_set_name']: d for d in tbl} @gherkin_ifc.step('The IfcPropertySet Name attribute value must use predefined values according to the "{table}" table') @@ -193,9 +205,7 @@ def upper_case_if_string(v): @gherkin_ifc.step('Each associated IfcProperty value must be of data type according to the property set definitions table "{table}"') def step_impl(context, inst, table): - tbl_path = system.get_abs_path(f"resources/property_set_definitions/{table}") - tbl = system.get_csv(tbl_path, return_type='dict') - property_set_definitions = {d['property_set_name']: d for d in tbl} + property_set_definitions = get_pset_definitions(context, table) def establish_accepted_pset_values(name, property_set_definitions): def make_obj(s):