# Path: business_logic/blockly/data.py
# REVERSE_OPERATOR_TABLE = {
#     block_type: {blockly: internal for internal, blockly in operators.items()
#                 } for block_type, operators in OPERATOR_TABLE.items()
# }


import datetime
from lxml import etree, objectify
from django.utils.six import StringIO
from ..models import *
from ..utils import get_content_type_id
from .data import REVERSE_OPERATOR_TABLE
from .exceptions import BlocklyXmlParserException
        for child in node.getchildren() if children is None else children:
            child_data = self.visit(child)
            if child_data is not None:
                data['children'].append(child_data)

    def _visit_single_child(self, node):
        children = node.getchildren()

        if len(children) != 1:
            raise BlocklyXmlParserException(
                'Incorrect number of children ({}) for BlocklyXmlParser._visit_single_child()'.format(len(children)))

        return self.visit(children[0])

    def _visit_simple_container(self, node, cls):
        data = {
            'data': {
                'content_type': get_content_type_id(cls),
            }
        }

        self._visit_children(node, data)

        return data

    def _visit_binary_operator(self, node):
        operator, lft_operand, rgh_operand = node.getchildren()
        data = {
            'data': {
                'content_type': get_content_type_id(BinaryOperator),

# Path: business_logic/blockly/data.py
# REVERSE_OPERATOR_TABLE = {
#     block_type: {blockly: internal for internal, blockly in operators.items()
#                 } for block_type, operators in OPERATOR_TABLE.items()
# }


# Path: business_logic/blockly/parse.py
import datetime
from lxml import etree, objectify
from django.utils.six import StringIO
from ..models import *
from ..utils import get_content_type_id
from .data import REVERSE_OPERATOR_TABLE
from .exceptions import BlocklyXmlParserException

        for child in node.getchildren() if children is None else children:
            child_data = self.visit(child)
            if child_data is not None:
                data['children'].append(child_data)

    def _visit_single_child(self, node):
        children = node.getchildren()

        if len(children) != 1:
            raise BlocklyXmlParserException(
                'Incorrect number of children ({}) for BlocklyXmlParser._visit_single_child()'.format(len(children)))

        return self.visit(children[0])

    def _visit_simple_container(self, node, cls):
        data = {
            'data': {
                'content_type': get_content_type_id(cls),
            }
        }

        self._visit_children(node, data)

        return data

    def _visit_binary_operator(self, node):
        operator, lft_operand, rgh_operand = node.getchildren()
        data = {
            'data': {
                'content_type': get_content_type_id(BinaryOperator),

                'operator': REVERSE_OPERATOR_TABLE[node.get('type')][operator.text]