# Path: business_logic/blockly/data.py
# OPERATOR_TABLE = {
#     'math_arithmetic': {
#         '+': 'ADD',
#         '-': 'MINUS',
#         '*': 'MULTIPLY',
#         '/': 'DIVIDE',
#         '^': 'POWER',
#     },
#     'logic_compare': {
#         '==': 'EQ',
#         '!=': 'NEQ',
#         '<': 'LT',
#         '<=': 'LTE',
#         '>': 'GT',
#         '>=': 'GTE',
#     },
#     'logic_operation': {
#         '&': 'AND',
#         '|': 'OR',
#     },
# }


import inspect
import logging
import re
from lxml import etree
from django.db.models import Model
from ..models import *
from .data import OPERATOR_TABLE
from .exceptions import BlocklyXmlBuilderException

    def visit_variable(self, node, parent_xml):
        block_type = self._get_variable_block_type(node, 'get')
        block = etree.SubElement(parent_xml, 'block', type=block_type)
        self._visit_variable(node, block)
        return block

    def visit_assignment(self, node, parent_xml):
        lhs_node, rhs_node = self.get_children(node)
        block_type = self._get_variable_block_type(lhs_node, 'set')
        block = etree.SubElement(parent_xml, 'block', type=block_type)
        self._visit_variable(lhs_node, block)
        value = etree.SubElement(block, 'value', name='VALUE')
        self.visit(rhs_node, value)
        return block

    visit_assignment.process_children = True

    def _visit_variable(self, node, parent_xml):
        variable = node.content_object
        field_element = etree.SubElement(parent_xml, 'field', name='VAR')
        field_element.text = variable.definition.name

    def visit_binary_operator(self, node, parent_xml):

        # determine block_type
        operator_value = node.content_object.operator
        block_type = None
        table = None


# Path: business_logic/blockly/data.py
# OPERATOR_TABLE = {
#     'math_arithmetic': {
#         '+': 'ADD',
#         '-': 'MINUS',
#         '*': 'MULTIPLY',
#         '/': 'DIVIDE',
#         '^': 'POWER',
#     },
#     'logic_compare': {
#         '==': 'EQ',
#         '!=': 'NEQ',
#         '<': 'LT',
#         '<=': 'LTE',
#         '>': 'GT',
#         '>=': 'GTE',
#     },
#     'logic_operation': {
#         '&': 'AND',
#         '|': 'OR',
#     },
# }


# Path: business_logic/blockly/build.py
import inspect
import logging
import re
from lxml import etree
from django.db.models import Model
from ..models import *
from .data import OPERATOR_TABLE
from .exceptions import BlocklyXmlBuilderException


    def visit_variable(self, node, parent_xml):
        block_type = self._get_variable_block_type(node, 'get')
        block = etree.SubElement(parent_xml, 'block', type=block_type)
        self._visit_variable(node, block)
        return block

    def visit_assignment(self, node, parent_xml):
        lhs_node, rhs_node = self.get_children(node)
        block_type = self._get_variable_block_type(lhs_node, 'set')
        block = etree.SubElement(parent_xml, 'block', type=block_type)
        self._visit_variable(lhs_node, block)
        value = etree.SubElement(block, 'value', name='VALUE')
        self.visit(rhs_node, value)
        return block

    visit_assignment.process_children = True

    def _visit_variable(self, node, parent_xml):
        variable = node.content_object
        field_element = etree.SubElement(parent_xml, 'field', name='VAR')
        field_element.text = variable.definition.name

    def visit_binary_operator(self, node, parent_xml):

        # determine block_type
        operator_value = node.content_object.operator
        block_type = None
        table = None


        for block_type, table in OPERATOR_TABLE.items():