Ejemplo n.º 1
0
    def parse_type2_condition(self, expression, branch):
        response = self.get_condition_name(expression)
        name = response[0]
        local = response[1]

        condition = TemplateType2ConditionNode(name=name, local=local)

        branch.append(condition)

        for child in expression:
            if child.tag == 'name':
                # Pass on this attribute as we have already pulled it from the get_condition_name above
                pass

            elif child.tag == 'var':
                # Pass on this attribute as we have already pulled it from the get_condition_name above
                pass

            elif child.tag == 'li':

                list_item = TemplateConditionListItemNode()

                list_item.value = self.get_condition_value(child, False)
                list_item.local = condition.local

                condition.children.append(list_item)
                self.parse_text(self.get_text_from_element(child), list_item)

                for sub_pattern in child:

                    if sub_pattern.tag == 'name':
                        pass

                    elif sub_pattern.tag == 'var':
                        pass

                    elif sub_pattern.tag == 'value':
                        pass

                    elif sub_pattern.tag == 'loop':
                        list_item.loop = True

                    else:
                        self.parse_tag_expression(sub_pattern, list_item)

                    tail_text = self.get_tail_from_element(sub_pattern)
                    self.parse_text(tail_text, list_item)

            else:
                raise ParserException("Error, invalid element <%s> in condition element" % (child.tag), xml_element=expression)
Ejemplo n.º 2
0
    def parse_type3_condition(self, expression, branch):
        condition = TemplateType3ConditionNode()
        branch.append(condition)

        for child in expression:

            if child.tag == 'name':
                pass

            elif child.tag == 'var':
                pass

            elif child.tag == 'li':
                list_item = TemplateConditionListItemNode()

                response = self.get_condition_name(child, False)
                list_item.name = response[0]
                list_item.local = response[1]

                list_item.value = self.get_condition_value(child, False)

                condition.append(list_item)

                self.parse_text(self.get_text_from_element(child), list_item)

                for sub_pattern in child:
                    if sub_pattern.tag == 'name':
                        pass

                    elif sub_pattern.tag == 'var':
                        pass

                    elif sub_pattern.tag == 'value':
                        pass

                    elif sub_pattern.tag == 'loop':
                        list_item.loop = True

                    else:
                        self.parse_tag_expression(sub_pattern, list_item)

                    tail_text = self.get_tail_from_element(sub_pattern)
                    self.parse_text(tail_text, list_item)

            else:
                raise ParserException("Error, invalid element <%s> in condition element" % (child.tag), xml_element=expression)