mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Adapt codegen for new parsing
This commit is contained in:
@@ -414,7 +414,7 @@ def process_expression(context):
|
|||||||
is_literal_str_list = False
|
is_literal_str_list = False
|
||||||
if is_literal_str_list:
|
if is_literal_str_list:
|
||||||
a, b = map(str, context.simple_expression.branches())
|
a, b = map(str, context.simple_expression.branches())
|
||||||
return f"{a}.lower() {str(context.rel_op_extended)} {b}"
|
return f"{a}.lower() {str(context.rel_op_extended)} map(str.lower, {b})"
|
||||||
return concat(context.rel_op_extended, context.simple_expression)
|
return concat(context.rel_op_extended, context.simple_expression)
|
||||||
elif context.multiplication_like_op:
|
elif context.multiplication_like_op:
|
||||||
if str(context.multiplication_like_op.branches()[0]) == "||":
|
if str(context.multiplication_like_op.branches()[0]) == "||":
|
||||||
@@ -695,6 +695,14 @@ codegen_rule("MOD", lambda context: "%")
|
|||||||
codegen_rule("TRUE", lambda context: "True")
|
codegen_rule("TRUE", lambda context: "True")
|
||||||
codegen_rule("FALSE", lambda context: "False")
|
codegen_rule("FALSE", lambda context: "False")
|
||||||
|
|
||||||
|
def _dotted_name(node: ast.AST):
|
||||||
|
"""Return dotted name for Name/Attribute chains, else None."""
|
||||||
|
if isinstance(node, ast.Name):
|
||||||
|
return node.id
|
||||||
|
if isinstance(node, ast.Attribute):
|
||||||
|
base = _dotted_name(node.value)
|
||||||
|
return f"{base}.{node.attr}" if base else node.attr
|
||||||
|
return None
|
||||||
|
|
||||||
class AttributeGetattrTransformer(ast.NodeTransformer):
|
class AttributeGetattrTransformer(ast.NodeTransformer):
|
||||||
def visit_Attribute(self, node):
|
def visit_Attribute(self, node):
|
||||||
@@ -712,7 +720,7 @@ class AttributeGetattrTransformer(ast.NodeTransformer):
|
|||||||
if isinstance(node.ctx, ast.Store):
|
if isinstance(node.ctx, ast.Store):
|
||||||
return node
|
return node
|
||||||
|
|
||||||
if node.attr == "create_entity":
|
if _dotted_name(node) in ('ifcopenshell.create_entity', 'str.lower'):
|
||||||
return node
|
return node
|
||||||
|
|
||||||
if node.attr.startswith("__"):
|
if node.attr.startswith("__"):
|
||||||
@@ -928,11 +936,11 @@ def typeof(inst):
|
|||||||
if not inst:
|
if not inst:
|
||||||
# If V evaluates to indeterminate (?), an empty set is returned.
|
# If V evaluates to indeterminate (?), an empty set is returned.
|
||||||
return express_set([])
|
return express_set([])
|
||||||
schema_name = inst.is_a(True).split('.')[0].lower()
|
schema_name = inst.is_a(True).split('.')[0].upper()
|
||||||
def inner():
|
def inner():
|
||||||
decl = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(inst.is_a())
|
decl = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(inst.is_a())
|
||||||
while decl:
|
while decl:
|
||||||
yield '.'.join((schema_name, decl.name().lower()))
|
yield '.'.join((schema_name, decl.name().upper()))
|
||||||
if isinstance(decl, ifcopenshell.ifcopenshell_wrapper.entity):
|
if isinstance(decl, ifcopenshell.ifcopenshell_wrapper.entity):
|
||||||
decl = decl.supertype()
|
decl = decl.supertype()
|
||||||
else:
|
else:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -46,4 +46,4 @@ def test_file(filename):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pytest.main(["-sx", __file__])
|
pytest.main(["-sx", __file__, '--import-mode=importlib'])
|
||||||
|
|||||||
Reference in New Issue
Block a user