Use schema_identifier for schema and express rule validation. See #3126

This commit is contained in:
Thomas Krijnen
2023-10-12 10:37:44 +02:00
parent 55e61b55d8
commit 81b4e42ca2
3 changed files with 7 additions and 4 deletions
@@ -27,6 +27,9 @@ import numbers
import itertools
import operator
import functools
import subprocess
import sys
import time
from . import ifcopenshell_wrapper
from . import settings
@@ -81,7 +81,7 @@ def run(f, logger):
orig = ifcopenshell.settings.unpack_non_aggregate_inverses
ifcopenshell.settings.unpack_non_aggregate_inverses = True
fn = os.path.join(os.path.dirname(__file__), "rules", f"{f.schema}.py")
fn = os.path.join(os.path.dirname(__file__), "rules", f"{f.schema_identifier}.py")
try:
source = open(fn, "r").read()
except FileNotFoundError as e:
@@ -90,7 +90,7 @@ def run(f, logger):
import subprocess
current_dir_files = {fn.lower(): fn for fn in os.listdir('.')}
schema_name = str(f.schema).split(' ')[-1].lower()
schema_name = str(f.schema_identifier).split(' ')[-1].lower()
schema_path = current_dir_files.get(schema_name + '.exp')
fn = schema_path[:-4] + '.py'
if not os.path.exists(fn):
@@ -100,7 +100,7 @@ def run(f, logger):
a = ast.parse(source)
assertion.rewrite.rewrite_asserts(mod=a, source=source)
cd = compile(a, f"{f.schema}.py", "exec")
cd = compile(a, f"{f.schema_identifier}.py", "exec")
scope = {}
exec(cd, scope)
S = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema_identifier)
@@ -328,7 +328,7 @@ def validate(f, logger, express_rules=False):
log_internal_cpp_errors(filename, logger)
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema)
schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema_identifier)
for inst in f:
if hasattr(logger, "set_state"):
logger.set_state('instance', inst)