mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
black .
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ def _create_offset_curve_representation(
|
||||
expected_type = "IfcAlignment"
|
||||
if not alignment.is_a(expected_type):
|
||||
raise TypeError(f"Expected {expected_type} but got {alignment.is_a()}")
|
||||
|
||||
|
||||
expected_type = "IfcPointByDistanceExpression"
|
||||
for offset in offsets:
|
||||
if not offset.is_a(expected_type):
|
||||
|
||||
@@ -217,7 +217,8 @@ for id in to_emit:
|
||||
statements.append("%s << %s" % (id, stmt))
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(r"""
|
||||
print(
|
||||
r"""
|
||||
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -256,4 +257,6 @@ if __name__ == "__main__":
|
||||
mdl = importlib.import_module(output)
|
||||
mdl.Generator(m).emit()
|
||||
sys.stdout.write(m.schema.name)
|
||||
""" % ("\n ".join(statements)))
|
||||
"""
|
||||
% ("\n ".join(statements))
|
||||
)
|
||||
|
||||
@@ -363,18 +363,24 @@ class EarlyBoundCodeWriter:
|
||||
)
|
||||
)
|
||||
|
||||
self.statements[self.statements.index("{factory_placeholder}")] = """
|
||||
self.statements[self.statements.index("{factory_placeholder}")] = (
|
||||
"""
|
||||
class %(schema_name)s_instance_factory : public IfcParse::instance_factory {
|
||||
virtual IfcUtil::IfcBaseClass* operator()(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) const {
|
||||
%(instance_mapping)s
|
||||
}
|
||||
};
|
||||
""" % locals()
|
||||
"""
|
||||
% locals()
|
||||
)
|
||||
|
||||
""
|
||||
self.statements[self.statements.index("{string_pool_placeholder}")] = """
|
||||
self.statements[self.statements.index("{string_pool_placeholder}")] = (
|
||||
"""
|
||||
const std::string strings[] = {%s};
|
||||
""" % ",".join(map(lambda s: '"%s"s' % s, self.strings))
|
||||
"""
|
||||
% ",".join(map(lambda s: '"%s"s' % s, self.strings))
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join(self.statements)
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestFormat(test.bootstrap.IFC4):
|
||||
def test_number_formatting(self):
|
||||
assert subject.format("round(123, 5)") == "125"
|
||||
assert subject.format('round("123", 5)') == "125"
|
||||
assert subject.format('round(-123, 5)') == "-125"
|
||||
assert subject.format("round(-123, 5)") == "-125"
|
||||
assert subject.format("int(123.123)") == "123"
|
||||
assert subject.format("int(123)") == "123"
|
||||
assert subject.format("number(123)") == "123"
|
||||
@@ -79,14 +79,14 @@ class TestFormat(test.bootstrap.IFC4):
|
||||
assert subject.format('imperial_length(3.0, 4, "foot", "foot", False)') == "3' - 0\""
|
||||
|
||||
def test_variable_formatting(self):
|
||||
assert subject.format('{{undefined}}') is None
|
||||
assert subject.format('upper({{undefined}})') == "NONE"
|
||||
assert subject.format('int({{undefined}})') == "0"
|
||||
assert subject.format("{{undefined}}") is None
|
||||
assert subject.format("upper({{undefined}})") == "NONE"
|
||||
assert subject.format("int({{undefined}})") == "0"
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
assert subject.format('{{undefined}}', element) is None
|
||||
assert subject.format('{{class}}', element) == "IfcWall"
|
||||
assert subject.format('{{ class }}', element) == "IfcWall"
|
||||
assert subject.format('upper({{ class }})', element) == "IFCWALL"
|
||||
assert subject.format("{{undefined}}", element) is None
|
||||
assert subject.format("{{class}}", element) == "IfcWall"
|
||||
assert subject.format("{{ class }}", element) == "IfcWall"
|
||||
assert subject.format("upper({{ class }})", element) == "IFCWALL"
|
||||
|
||||
def test_list_formatting(self):
|
||||
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
@@ -98,17 +98,17 @@ class TestFormat(test.bootstrap.IFC4):
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material2)
|
||||
layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material3)
|
||||
ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set)
|
||||
assert subject.format('{{materials.Name}}', element) == "CON01, CON03, CON02"
|
||||
assert subject.format('sort({{materials.Name}})', element) == "CON01, CON02, CON03"
|
||||
assert subject.format('reverse({{materials.Name}})', element) == "CON02, CON03, CON01"
|
||||
assert subject.format("{{materials.Name}}", element) == "CON01, CON03, CON02"
|
||||
assert subject.format("sort({{materials.Name}})", element) == "CON01, CON02, CON03"
|
||||
assert subject.format("reverse({{materials.Name}})", element) == "CON02, CON03, CON01"
|
||||
assert subject.format('join("-", {{materials.Name}})', element) == "CON01-CON03-CON02"
|
||||
|
||||
def test_expressions(self):
|
||||
assert subject.format('2+3') == "5"
|
||||
assert subject.format('-2+3') == "1"
|
||||
assert subject.format('2-3') == "-1"
|
||||
assert subject.format('3*2') == "6"
|
||||
assert subject.format('3/2') == "1.5"
|
||||
assert subject.format("2+3") == "5"
|
||||
assert subject.format("-2+3") == "1"
|
||||
assert subject.format("2-3") == "-1"
|
||||
assert subject.format("3*2") == "6"
|
||||
assert subject.format("3/2") == "1.5"
|
||||
|
||||
|
||||
class TestGetElementValue(test.bootstrap.IFC4):
|
||||
|
||||
Reference in New Issue
Block a user