mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 08:45:22 +00:00
Use schema_identifier for schema and express rule validation. See #3126
This commit is contained in:
@@ -27,6 +27,9 @@ import numbers
|
|||||||
import itertools
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
import functools
|
import functools
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from . import ifcopenshell_wrapper
|
from . import ifcopenshell_wrapper
|
||||||
from . import settings
|
from . import settings
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ def run(f, logger):
|
|||||||
orig = ifcopenshell.settings.unpack_non_aggregate_inverses
|
orig = ifcopenshell.settings.unpack_non_aggregate_inverses
|
||||||
ifcopenshell.settings.unpack_non_aggregate_inverses = True
|
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:
|
try:
|
||||||
source = open(fn, "r").read()
|
source = open(fn, "r").read()
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -90,7 +90,7 @@ def run(f, logger):
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
current_dir_files = {fn.lower(): fn for fn in os.listdir('.')}
|
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')
|
schema_path = current_dir_files.get(schema_name + '.exp')
|
||||||
fn = schema_path[:-4] + '.py'
|
fn = schema_path[:-4] + '.py'
|
||||||
if not os.path.exists(fn):
|
if not os.path.exists(fn):
|
||||||
@@ -100,7 +100,7 @@ def run(f, logger):
|
|||||||
|
|
||||||
a = ast.parse(source)
|
a = ast.parse(source)
|
||||||
assertion.rewrite.rewrite_asserts(mod=a, source=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 = {}
|
scope = {}
|
||||||
exec(cd, scope)
|
exec(cd, scope)
|
||||||
S = ifcopenshell.ifcopenshell_wrapper.schema_by_name(f.schema_identifier)
|
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)
|
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:
|
for inst in f:
|
||||||
if hasattr(logger, "set_state"):
|
if hasattr(logger, "set_state"):
|
||||||
logger.set_state('instance', inst)
|
logger.set_state('instance', inst)
|
||||||
|
|||||||
Reference in New Issue
Block a user