Exemplo n.º 1
0
def _create_code_from_statements(sorted_statements, inputs, context, \
                                 indents_amount=8, reserved_inputs=[]):
                        
    stat_list = []
    for stmt in sorted_statements:
        if isinstance(stmt,GeneralExpression):
            stat_list.append(reindent(stmt.call_signature,indents_amount))
        elif isinstance(stmt,FunctionCallGroup):
            stat_list.append(reindent(stmt.gfunc.call_signature,indents_amount))
            if stmt.gfunc.type=='plain':
                add_space = 0
            else:
                add_space = 4
            reserved_inputs = stmt.gfunc.reserved_inputs
            stat_list.append(reindent(_create_code_from_statements(stmt.group_statements,
                                             inputs,
                                             context,
                                             indents_amount=indents_amount+add_space,
                                             reserved_inputs = reserved_inputs),
                                      indents_amount))
        else:
            stat_list.append(reindent(_statement_static_signature(stmt,
                                                                  inputs,
                                                                  context,
                                                                  reserved_inputs=reserved_inputs),
                                      indents_amount))
                  
    return ' \n'.join(stat_list)
Exemplo n.º 2
0
def _create_code_from_imports_and_locals(imports_and_locals, \
                                         indents_amount=4):
        
    return ' \n'.join(reindent(import_statement,indents_amount) \
                      for import_statement in \
                      imports_and_locals.splitlines() \
                      if import_statement != '')