ifcopenshell.express.rule_compiler

Module Contents

class ifcopenshell.express.rule_compiler.AttributeGetattrTransformer

Bases: ast.NodeTransformer

A NodeVisitor subclass that walks the abstract syntax tree and allows modification of nodes.

The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is None, the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place.

Here is an example transformer that rewrites all occurrences of name lookups (foo) to data['foo']:

class RewriteName(NodeTransformer):

    def visit_Name(self, node):
        return Subscript(
            value=Name(id='data', ctx=Load()),
            slice=Constant(value=node.id),
            ctx=node.ctx
        )

Keep in mind that if the node you’re operating on has child nodes you must either transform the child nodes yourself or call the generic_visit() method for the node first.

For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node.

Usually you use the transformer like this:

node = YourTransformer().visit(node)
assign_parent_refs(tree)
visit_Attribute(node)
visit_Subscript(node)
class ifcopenshell.express.rule_compiler.codegen_rule(pattern, fn)
static apply(G)
class ifcopenshell.express.rule_compiler.context(graph, rules)
branch(i)
branches(allow_multiple=False, exclude=())
descendants()
has_inverse(a)
key()
parent()
class ifcopenshell.express.rule_compiler.empty
ifcopenshell.express.rule_compiler.make_lowercase(context)
ifcopenshell.express.rule_compiler.make_lowercase_if(fn)
ifcopenshell.express.rule_compiler.paths(G, root, length)
ifcopenshell.express.rule_compiler.process_aggregate_initializer(context)
ifcopenshell.express.rule_compiler.process_assignment(context)
ifcopenshell.express.rule_compiler.process_case_action(context)
ifcopenshell.express.rule_compiler.process_case_statement(context)
ifcopenshell.express.rule_compiler.process_domain_rule(context)
ifcopenshell.express.rule_compiler.process_expression(context)
ifcopenshell.express.rule_compiler.process_function_call(context)
ifcopenshell.express.rule_compiler.process_function_decl(context)
ifcopenshell.express.rule_compiler.process_if_stmt(context)
ifcopenshell.express.rule_compiler.process_index(context)
ifcopenshell.express.rule_compiler.process_interval(context)
ifcopenshell.express.rule_compiler.process_local_variable(context)
ifcopenshell.express.rule_compiler.process_query(context)
ifcopenshell.express.rule_compiler.process_rel_op(context)
ifcopenshell.express.rule_compiler.process_repeat_stmt(context)
ifcopenshell.express.rule_compiler.process_rule_decl(context)
ifcopenshell.express.rule_compiler.process_type_decl(scope, context)
ifcopenshell.express.rule_compiler.simple_concat(context)
ifcopenshell.express.rule_compiler.to_graph(tree)
ifcopenshell.express.rule_compiler.wrap_parens(s)
ifcopenshell.express.rule_compiler.write_dot(fn, g)
ifcopenshell.express.rule_compiler.DEBUG = False
ifcopenshell.express.rule_compiler.SLASH
ifcopenshell.express.rule_compiler.context_class
ifcopenshell.express.rule_compiler.identifier
ifcopenshell.express.rule_compiler.rule
ifcopenshell.express.rule_compiler.schema
ifcopenshell.express.rule_compiler.wb = '\\b'