mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from behave import step
|
|
|
|
from attributes_psets_methods import all_eleclass_elements_have_prop_in_pset
|
|
from utils import assert_elements
|
|
from utils import IfcFile
|
|
from utils import switch_locale
|
|
|
|
|
|
@step("all {ifc_class} elements have an {aproperty} property in the {pset} pset")
|
|
def step_impl(context, ifc_class, aproperty, pset):
|
|
switch_locale(context.localedir, "en")
|
|
all_eleclass_elements_have_prop_in_pset(context, ifc_class, aproperty, pset)
|
|
|
|
|
|
# ------------------------------------------------------------------------
|
|
# STEPS with Regular Expression Matcher ("re")
|
|
# ------------------------------------------------------------------------
|
|
use_step_matcher("re")
|
|
|
|
|
|
@step("all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property")
|
|
def step_impl(context, ifc_class, property_path):
|
|
pset_name, property_name = property_path.split(".")
|
|
elements = IfcFile.get().by_type(ifc_class)
|
|
for element in elements:
|
|
if not IfcFile.get_property(element, pset_name, property_name):
|
|
assert False
|
|
|
|
|
|
@step(
|
|
'all (?P<ifc_class>.*) elements have an? (?P<property_path>.*\..*) property value matching the pattern "(?P<pattern>.*)"'
|
|
)
|
|
def step_impl(context, ifc_class, property_path, pattern):
|
|
import re
|
|
|
|
pset_name, property_name = property_path.split(".")
|
|
elements = IfcFile.get().by_type(ifc_class)
|
|
for element in elements:
|
|
prop = IfcFile.get_property(element, pset_name, property_name)
|
|
if not prop:
|
|
assert False
|
|
# For now, we only check single values
|
|
if prop.is_a("IfcPropertySingleValue"):
|
|
if not (prop.NominalValue and re.search(pattern, prop.NominalValue.wrappedValue)):
|
|
assert False
|