Exemplo n.º 1
0
 def parse_event(event_dict):
     name = get_element(event_dict, "name")
     value = get_element(event_dict, "value")
     if not (name and value):
         log("Invalid arg name and value for ConditionnalEvent", 1)
         return None
     if_event = None
     if_event_dict = get_element(event_dict, "if_event")
     if if_event_dict:
         if_event = parse_event_json(if_event_dict)
     else_event = None
     else_event_dict = get_element(event_dict, "else_event")
     if else_event_dict:
         else_event = parse_event_json(else_event_dict)
     return ConditionnalEvent(name, value, if_event, else_event)
Exemplo n.º 2
0
    def parse_event(event_dict):
        """Dynamic parsing of DialogEvent"""
        text = get_element(event_dict, "text")
        if text is None:
            return None
        text2 = get_element(event_dict, "text2")
        if text2 is None:
            text2 = ''

        dialog_event = DialogEvent(get_level(), text, text2)
        answers = get_element(event_dict, "answers")
        if answers is not None:
            for answer_key in answers:
                if isinstance(answers[answer_key],dict):
                    answers[answer_key] = parse_event_json(answers[answer_key], dialog_event)
                elif isinstance(answers[answer_key], CONST.string_type):
                    answers[answer_key] = load_event(answers[answer_key], dialog_event)

            dialog_event.set_answers(answers)
        return dialog_event