Fix #2945. Selector should expand enumerated list properties so that you can match any of them.

This commit is contained in:
Dion Moult
2023-04-06 19:21:14 +10:00
parent 884ee5b587
commit 6c5acfc8bb
2 changed files with 5 additions and 1 deletions
@@ -293,7 +293,10 @@ class Selector:
results = []
for prop_name, prop_value in value.items():
if re.match(key, prop_name):
results.append(prop_value)
if isinstance(prop_value, (list, tuple)):
results.extend(prop_value)
else:
results.append(prop_value)
value = results
else:
value = value.get(key, None)
@@ -88,6 +88,7 @@ class TestSelector(test.bootstrap.IFC4):
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
assert subject.Selector.parse(self.file, ".IfcElement[Foo_Bar.Foo]") == [element]
assert subject.Selector.parse(self.file, ".IfcElement[Foo_Bar.Fox]") == []
assert subject.Selector.parse(self.file, '.IfcElement[r"Foo.*ar"."Fo.*"]') == [element]
def test_selecting_by_string_property(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")