Exemplo n.º 1
0
    def test_job_transmission(self):
        self.awake_single()
        # campaignをセット
        campaign = Campaign(author="cxxx0",
                            requirement=Requirement(values=["zero", "random"],
                                                    trigger={"timer": 1}),
                            trigger={"timer": 5},
                            place="All",
                            purpose="test_purpose",
                            destination="mongodb://localhost:27017/")
        clients["cxxx0"].post('/commander/campaigns',
                              data=json.dumps(campaign.to_dict()),
                              content_type='application/json')
        time.sleep(1.5)  # heartbeatを待つ; 0.7 + 0.4 + alpha

        # missionを確認
        mission = Mission(author="lxxx0",
                          requirement=Requirement(values=["zero", "random"],
                                                  trigger={"timer": 1}),
                          trigger={"timer": 5},
                          place="All",
                          purpose=campaign.get_id())
        self.assertIn(mission, self.models["lxxx0"].missions.values())

        # orderを確認
        order = Order(author="sxxx0",
                      values=["zero", "random"],
                      trigger={"timer": 1},
                      purpose=mission.get_id())
        self.assertIn(order, self.models["sxxx0"].orders.values())
Exemplo n.º 2
0
    def accept_mission(self, mission: Mission) -> Mission:
        # Missionの更新であれば(=IDが同じであれば)既存のものを消す
        if mission.get_id() in self.missions:
            self.remove_mission(mission.get_id())

        # 部下のOrderを生成・割り当てる
        target_subs = []
        if mission.place == "All":
            target_subs = list(self.subordinates.values())
        for sol in target_subs:
            m_req = mission.requirement
            values = list(set(m_req.values).intersection(sol.weapons))
            order = Order(author=sol.id,
                          values=values,
                          trigger=m_req.trigger,
                          purpose=mission.get_id())
            sol.orders.append(order)

        # 自身のデータ送信スレッドを生成する
        th = WorkingThread(self, mission)
        self.working_threads.append(th)
        th.start()

        self.missions[mission.get_id()] = mission
        return mission
Exemplo n.º 3
0
    def accept_mission(self, mission: Mission) -> Mission:
        # Missionの更新であれば(=IDが同じであれば)既存のものを消す
        if mission.get_id() in self.missions:
            self.remove_mission(mission.get_id())

        # 部下のOrderを生成・割り当てる
        target_subs = []
        if mission.place == "All":
            target_subs = list(self.subordinates.values())
        for sol in target_subs:
            m_req = mission.requirement
            values = list(set(m_req.values).intersection(sol.weapons))
            order = Order(author=sol.id,
                          values=values,
                          trigger=m_req.trigger,
                          purpose=mission.get_id())
            sol.orders.append(order)

        # 自身のデータ送信スレッドを生成する
        th = WorkingThread(self, mission)
        self.working_threads.append(th)
        th.start()

        self.missions[mission.get_id()] = mission
        return mission
Exemplo n.º 4
0
    def test_job_transmission(self):
        self.awake_single()
        # campaignをセット
        campaign = Campaign(author="cxxx0",
                            requirement=Requirement(values=["zero", "random"],
                                                    trigger={"timer": 1}),
                            trigger={"timer": 5},
                            place="All",
                            purpose="test_purpose",
                            destination="mongodb://localhost:27017/")
        clients["cxxx0"].post('/commander/campaigns',
                              data=json.dumps(campaign.to_dict()),
                              content_type='application/json')
        time.sleep(1.5)  # heartbeatを待つ; 0.7 + 0.4 + alpha

        # missionを確認
        mission = Mission(author="lxxx0",
                          requirement=Requirement(values=["zero", "random"],
                                                  trigger={"timer": 1}),
                          trigger={"timer": 5},
                          place="All",
                          purpose=campaign.get_id())
        self.assertIn(mission, self.models["lxxx0"].missions.values())

        # orderを確認
        order = Order(author="sxxx0",
                      values=["zero", "random"],
                      trigger={"timer": 1},
                      purpose=mission.get_id())
        self.assertIn(order, self.models["sxxx0"].orders.values())
Exemplo n.º 5
0
    def __init__(self, lines):
        tokens = shlex.split(lines[0])
        self.mission = Mission(tokens[1])
        self.mission.lines = lines
        self.lines = self.mission.lines

        self.i = None
        self.line = None
        self.enum_lines = enumerate(self.lines)

        self.logMessagePattern = re.compile(r'^ *')
Exemplo n.º 6
0
    def _add_to_items_list(new_mission_name):
        logging.debug("Adding mission: \"%s\"..." % new_mission_name)

        mission = Mission(new_mission_name)
        config.mission_file_items.add_item(mission)
        config.active_item = mission
        config.gui.update_option_pane()
Exemplo n.º 7
0
 def make(cls, source: dict):
     try:
         return cls(source['id'], source['name'], source['place'],
                    source['endpoint'], source['subordinates'],
                    [Mission.make(m) for m in source['missions']])
     except KeyError:
         raise TypeError
Exemplo n.º 8
0
    def test_get_missions_multi(self):
        # add some missions
        mission_base = Mission(author='lxxx0',
                               place='on desk',
                               purpose='A great app',
                               requirement=Requirement(
                                   values=["zero", "random"],
                                   trigger={"timer": 10}),
                               trigger={"timer": 30})
        mission_list = []
        for purpose in ['on chair', 'front of door', 'on desk', 'living room']:
            m = copy.deepcopy(mission_base)
            m.purpose = purpose
            mission_list.append(m)

        for m in mission_list:
            self.leader_obj.accept_mission(m)

        # get missions
        response = self.app.get('/leader/missions')
        self.assertEqual(response.status_code, 200)
        actual = loads(response.data.decode("utf-8"))
        actual_list = actual['missions']

        # assert status
        expected_status = {'success': True, 'msg': "status is ok"}
        self.assertEqual(actual['_status'], expected_status)

        # assert items
        expected_list = [c.to_dict() for c in mission_list]
        self.assertEqual(len(actual_list), len(expected_list))
        for exp in expected_list:
            if exp not in actual_list:
                self.fail('{0} is not found.'.format(exp))
        pass
Exemplo n.º 9
0
    def setup(self):
        self._logger_setup()
        logging.debug("Starting ESMB...")
        self._load_tooltips()
        self._setup_singletons()

        if "debug=True" in sys.argv:
            config.debugging = True
            config.mission_file_items.add_item(Mission("Debugging"))
            config.mission_file_items.items_list[0].type = "mission"
            config.active_item = config.mission_file_items.items_list[0]
Exemplo n.º 10
0
 def make(cls, source: dict):
     try:
         return cls(
             source['id'],
             source['name'],
             source['place'],
             source['endpoint'],
             source['subordinates'],
             [Mission.make(m) for m in source['missions']]
         )
     except KeyError:
         raise TypeError
Exemplo n.º 11
0
    def test_get_missions_single(self):
        # add a mission
        mission = Mission(author='lxxx0',
                          place='on desk',
                          purpose='A great app',
                          requirement=Requirement(
                              values=["zero", "random"],
                              trigger={"timer": 10}
                          ),
                          trigger={"timer": 30})
        self.leader_obj.accept_mission(mission)

        # get subordinates
        response = self.app.get('/leader/missions')
        self.assertEqual(response.status_code, 200)
        actual = loads(response.data.decode("utf-8"))

        # assert
        expected = {
            "_status": {'success': True, 'msg': "status is ok"},
            'missions': [mission.to_dict()]
        }
        self.assertEqual(actual, expected)
Exemplo n.º 12
0
    def test_get_missions_single(self):
        # add a mission
        mission = Mission(author='lxxx0',
                          place='on desk',
                          purpose='A great app',
                          requirement=Requirement(values=["zero", "random"],
                                                  trigger={"timer": 10}),
                          trigger={"timer": 30})
        self.leader_obj.accept_mission(mission)

        # get subordinates
        response = self.app.get('/leader/missions')
        self.assertEqual(response.status_code, 200)
        actual = loads(response.data.decode("utf-8"))

        # assert
        expected = {
            "_status": {
                'success': True,
                'msg': "status is ok"
            },
            'missions': [mission.to_dict()]
        }
        self.assertEqual(actual, expected)
Exemplo n.º 13
0
async def fit_mission(conn, inst):
    i = Mission(inst)
    try:
        await conn.fetch('begin;')
        await conn.fetch(f'''
            insert into missions values
              (DEFAULT, {i.name!r}, {i.fullname!r}, 
                (select id from payloads where name = {i.payloads[0]!r}))
        ''')
        for pid in i.payloads:
            await conn.fetch(f'''
                update payloads
                    set mission_id = (select id from missions where name = {i.name!r})
                where name = {pid!r};
            ''')
    except Exception:
        await conn.fetch('abort;')
        raise
    else:
        await conn.fetch('commit;')
Exemplo n.º 14
0
    def accept_campaign(self, campaign: Campaign):
        # Campaignの更新であれば(=IDが同じであれば)既存のものを消す
        if campaign.get_id() in self.campaigns:
            self.remove_campaign(campaign.get_id())

        # 部下のMissionを生成・割り当てる
        target_subs = []
        if campaign.place == "All":
            target_subs = list(self.subordinates.keys())
        m_base = Mission(author='',
                         place='All',
                         purpose=campaign.get_id(),
                         requirement=campaign.requirement,
                         trigger=campaign.trigger)
        for t_id in target_subs:
            mission = copy.deepcopy(m_base)
            mission.author = t_id
            self.subordinates[t_id].missions.append(mission)

        logger.info(">> got campaign:")
        logger.info(json.dumps(campaign.to_dict(), sort_keys=True, indent=2))
        self.campaigns[campaign.get_id()] = campaign
        return campaign
Exemplo n.º 15
0
    def test_missoin_do(self):
        def post_report(url, data=None, json=None, etag=None, **kwargs):
            res = requests.Response()
            res.status_code = 200
            res_dict = {
                "_status": {"msg": "ok", "success": True},
                "accepted": json
            }
            res._content = dumps(res_dict).encode()
            return res, None

        self.leader_obj.superior_ep = "test://cxxx0/commander/"
        soldier = SoldierInfo(id="sxxx0", name="sol-test", place="left",
                              weapons=[], orders=[])
        self.leader_obj.accept_subordinate(soldier)

        mission = Mission(author="sxxx0",
                          requirement=Requirement(
                              values=["zero", "random"],
                              trigger={"timer": 0.4}
                          ),
                          trigger={"timer": 0.7},
                          place="All",
                          purpose="some purpose hash")

        work_1 = Work(time=datetime.utcnow().isoformat(),
                      purpose=mission.get_id(),
                      values=[0, 0.584249])
        work_2 = Work(time=datetime.utcnow().isoformat(),
                      purpose=mission.get_id(),
                      values=[0, 0.238491])
        work_3 = Work(time=datetime.utcnow().isoformat(),
                      purpose="0" + mission.get_id()[:-1],  # 上2つとずらす
                      values=[0, 0.045066])
        self.leader_obj.accept_work("sxxx0", work_1)
        self.leader_obj.accept_work("sxxx0", work_2)
        self.leader_obj.accept_work("sxxx0", work_3)

        with patch("utils.rest.post", side_effect=post_report) as m:
            self.leader_obj.accept_mission(mission)
            time.sleep(1)
            self.assertEqual(m.call_count, 1)
            self.assertEqual(m.call_args[0][0],
                             "test://cxxx0/commander/subordinates/lxxx0/report")

            # reportのチェック
            actual = m.call_args[1]["json"]
            self.assertEqual(set(actual.keys()),
                             {"time", "place", "purpose", "values"})
            self.assertEqual(actual["purpose"], "some purpose hash")
            self.assertEqual(len(actual["values"]), 2)

            # report.valuesのチェック
            work_in_1 = work_1.to_dict()
            del work_in_1["purpose"]
            work_in_1["place"] = "left"
            work_in_2 = work_2.to_dict()
            del work_in_2["purpose"]
            work_in_2["place"] = "left"
            self.assertIn(work_in_1, actual["values"])
            self.assertIn(work_in_2, actual["values"])

        self.leader_obj.superior_ep = ""  # shutdownでDELETEを送信するのを阻止
Exemplo n.º 16
0
    def test_missoin_do(self):
        def post_report(url, data=None, json=None, etag=None, **kwargs):
            res = requests.Response()
            res.status_code = 200
            res_dict = {
                "_status": {
                    "msg": "ok",
                    "success": True
                },
                "accepted": json
            }
            res._content = dumps(res_dict).encode()
            return res, None

        self.leader_obj.superior_ep = "test://cxxx0/commander/"
        soldier = SoldierInfo(id="sxxx0",
                              name="sol-test",
                              place="left",
                              weapons=[],
                              orders=[])
        self.leader_obj.accept_subordinate(soldier)

        mission = Mission(author="sxxx0",
                          requirement=Requirement(values=["zero", "random"],
                                                  trigger={"timer": 0.4}),
                          trigger={"timer": 0.7},
                          place="All",
                          purpose="some purpose hash")

        work_1 = Work(time=datetime.utcnow().isoformat(),
                      purpose=mission.get_id(),
                      values=[0, 0.584249])
        work_2 = Work(time=datetime.utcnow().isoformat(),
                      purpose=mission.get_id(),
                      values=[0, 0.238491])
        work_3 = Work(
            time=datetime.utcnow().isoformat(),
            purpose="0" + mission.get_id()[:-1],  # 上2つとずらす
            values=[0, 0.045066])
        self.leader_obj.accept_work("sxxx0", work_1)
        self.leader_obj.accept_work("sxxx0", work_2)
        self.leader_obj.accept_work("sxxx0", work_3)

        with patch("utils.rest.post", side_effect=post_report) as m:
            self.leader_obj.accept_mission(mission)
            time.sleep(1)
            self.assertEqual(m.call_count, 1)
            self.assertEqual(
                m.call_args[0][0],
                "test://cxxx0/commander/subordinates/lxxx0/report")

            # reportのチェック
            actual = m.call_args[1]["json"]
            self.assertEqual(set(actual.keys()),
                             {"time", "place", "purpose", "values"})
            self.assertEqual(actual["purpose"], "some purpose hash")
            self.assertEqual(len(actual["values"]), 2)

            # report.valuesのチェック
            work_in_1 = work_1.to_dict()
            del work_in_1["purpose"]
            work_in_1["place"] = "left"
            work_in_2 = work_2.to_dict()
            del work_in_2["purpose"]
            work_in_2["place"] = "left"
            self.assertIn(work_in_1, actual["values"])
            self.assertIn(work_in_2, actual["values"])

        self.leader_obj.superior_ep = ""  # shutdownでDELETEを送信するのを阻止
Exemplo n.º 17
0
class FileMissionItemParser:
    """Parses a mission item from a file"""
    def __init__(self, lines):
        tokens = shlex.split(lines[0])
        self.mission = Mission(tokens[1])
        self.mission.lines = lines
        self.lines = self.mission.lines

        self.i = None
        self.line = None
        self.enum_lines = enumerate(self.lines)

        self.logMessagePattern = re.compile(r'^ *')

    #end init

    def run(self):
        logging.debug("\t\tParsing %s from file..." % self.mission.name)

        self.strip_ending_whitespace_from_lines()
        for self.i, self.line in self.enum_lines:
            self.line = self.line.rstrip()
            tokens = self.tokenize(self.line)

            # determine which attribute we've got
            if not tokens:
                continue
            if "mission" in tokens[0]:
                continue
            elif "name" in tokens[0]:
                self._parse_name(tokens)
            elif "description" in tokens[0]:
                self._parse_description(tokens)
            elif "blocked" in tokens[0]:
                self._parse_blocked(tokens)
            elif "deadline" in tokens[0]:
                self._parse_deadline(tokens)
            elif "cargo" in tokens[0]:
                self._parse_cargo(tokens)
            elif "passengers" in tokens[0]:
                self._parse_passengers(tokens)
            elif "illegal" in tokens[0]:
                self._parse_illegal(tokens)
            elif "stealth" in tokens[0]:
                self._parse_stealth()
            elif "invisible" in tokens[0]:
                self._parse_invisible()
            elif tokens[0] in ["priority", "minor"]:
                self._parse_priority_level(tokens)
            elif tokens[0] in ["job", "landing", "assisting", "boarding"]:
                self._parse_where_shown(tokens)
            elif "repeat" in tokens[0]:
                self._parse_repeat(tokens)
            elif "clearance" in tokens[0]:
                self._parse_clearance(tokens)
            elif "infiltrating" in tokens[0]:
                self._parse_infiltrating()
            elif "waypoint" in tokens[0]:
                self._parse_waypoint(tokens)
            elif "stopover" in tokens[0]:
                self._parse_stopover(tokens)
            elif "source" in tokens[0]:
                self._parse_source(tokens)
            elif "destination" in tokens[0]:
                self._parse_destination(tokens)
            elif "on" in tokens:
                self._parse_trigger(tokens)
            elif "to" in tokens:
                self._parse_condition()
            else:
                logging.debug("ERROR: No tokens found on line %d: %s" %
                              (self.i, self.line))
            #end if/elif/else
        #end for

        config.mission_file_items.add_item(self.mission)

    #end run

    def strip_ending_whitespace_from_lines(self):
        while self.lines[-1] == "" or self.lines[-1] == "\n":
            del self.lines[-1]

    #end strip_ending_whitespace_from_lines

    @staticmethod
    def tokenize(line):
        """Break the line into a list of tokens, saving anything inside quotes as a single token"""
        pattern = re.compile(r'((?:".*?")|(?:`.*?`)|[^\"\s]+)')
        tokens = re.findall(pattern, line)
        for i, token in enumerate(tokens):
            if token.startswith("`"):
                tokens[i] = token[1:-1]
            elif token.startswith("\""):
                tokens[i] = token[1:-1]
        return tokens

    # end tokenize

    @staticmethod
    def get_indent_level(line):
        tab_count = len(line) - len(line.lstrip('\t'))
        return tab_count

    # end get_indent_level

    @staticmethod
    def store_component_data(component, tokens):
        """
        Store the tokens in the given component

        :param component: The component the data will be stored in
        :param tokens: The tokens to store
        """
        for i, token in enumerate(tokens):
            if token is not None:
                component[i] = token
            else:
                break
            # end if/else
        # end for

    # end store_component_data

    def _parse_name(self, tokens):
        logging.debug("\t\t\tFound mission display name: \"%s\"" % tokens[1])
        self.mission.components.mission_display_name = tokens[1]

    #end _parse_name

    def _parse_description(self, tokens):
        logging.debug("\t\t\tFound description: %s" % tokens[1])
        self.mission.components.description = tokens[1]

    #end _parse_description

    def _parse_blocked(self, tokens):
        logging.debug("\t\t\tFound blocked: %s" % tokens[1])
        self.mission.components.blocked = tokens[1]

    #end _parse_blocked

    def _parse_deadline(self, tokens):
        logging.debug("\t\t\tFound deadline")
        self.mission.components.deadline.is_active = True
        self.store_component_data(self.mission.components.deadline.deadline,
                                  tokens[1:])

    #end _parse_deadline

    def _parse_cargo(self, tokens):
        logging.debug("\t\t\tFound cargo: %s" % tokens[1:])
        self.mission.components.cargo.is_active = True
        self.store_component_data(self.mission.components.cargo.cargo,
                                  tokens[1:])

    #end _parse_cargo

    def _parse_passengers(self, tokens):
        logging.debug("\t\t\tFound passengers: %s" % tokens[1:])
        self.mission.components.passengers.is_active = True
        self.store_component_data(
            self.mission.components.passengers.passengers, tokens[1:])

    #end _parse_passengers

    def _parse_illegal(self, tokens):
        logging.debug("\t\t\tFound illegal modifier: %s" % tokens[1:])
        self.mission.components.illegal.is_active = True
        self.store_component_data(self.mission.components.illegal.illegal,
                                  tokens[1:])

    #end _parse_illegal

    def _parse_stealth(self):
        logging.debug("\t\t\tFound stealth modifier")
        self.mission.components.is_stealth = True

    #end _parse_stealth

    def _parse_invisible(self):
        logging.debug("\t\t\tFound invisible modifier")
        self.mission.components.is_invisible = True

    #end _parse_invisible

    def _parse_priority_level(self, tokens):
        logging.debug("\t\t\tFound priority level")
        self.mission.components.priority_level = tokens[0]

    #end _parse_priority_level

    def _parse_where_shown(self, tokens):
        logging.debug("\t\t\tFound where shown")
        self.mission.components.where_shown = tokens[0]

    #end _parse_where_shown

    def _parse_repeat(self, tokens):
        logging.debug("\t\t\tFound repeat")
        self.mission.components.repeat.is_active = True
        if len(tokens) > 1:
            logging.debug("\t\t\t\tFound repeat optional data: %s" % tokens[1])
            self.mission.components.repeat.repeat = tokens[1]
        # end if

    #end _parse_repeat

    def _parse_clearance(self, tokens):
        logging.debug("\t\t\tFound clearance: %s" % tokens[1])
        self.mission.components.clearance.is_active = True
        self.mission.components.clearance.clearance = tokens[1]

    #end _parse_clearance

    def _parse_infiltrating(self):
        logging.debug("\t\t\tFound infiltrating")
        self.mission.components.is_infiltrating = True

    #end _parse_infiltrating

    def _parse_waypoint(self, tokens):
        logging.debug("\t\t\tFound waypoint: %s" % tokens[1])
        self.mission.components.waypoint = tokens[1]

    #end _parse_waypoint

    def _parse_stopover(self, tokens):
        logging.debug("\t\t\tFound stopover: %s" % tokens[1])
        self.mission.components.stopover.is_active = True
        self.mission.components.stopover.stopover = tokens[1]

    #end _parse_stopover

    def _parse_source(self, tokens):
        if len(tokens) == 2:
            logging.debug("\t\t\tFound source: %s" % tokens[1])
            self.mission.components.source.is_active = True
            self.mission.components.source.source = tokens[1]
        else:
            logging.error("COMPLEX SOURCE HANDLING NOT YET IMPLEMENTED")
        # end if/else

    #end _parse_source

    def _parse_destination(self, tokens):
        if len(tokens) == 2:
            logging.debug("\t\t\tFound destination: %s" % tokens[1])
            self.mission.components.destination.is_active = True
            self.mission.components.destination.destination = tokens[1]
        # end if

    #end _parse_destination

    def _parse_trigger(self, tokens):
        logging.debug("\t\t\tFound Trigger: on %s" % tokens[1])
        trigger = self.mission.add_trigger()
        trigger.is_active = True
        trigger.trigger_type = tokens[1]

        cur = self.get_indent_level(self.mission.lines[self.i])
        nxt = self.get_indent_level(self.mission.lines[self.i + 1])
        while True:
            if nxt <= cur:
                break
            self.i, self.line = self.enum_lines.__next__()
            self.line = self.line.rstrip()
            tokens = self.tokenize(self.line)

            if "conversation" in tokens[0]:
                self._parse_conversation(tokens)
            elif "dialog" in tokens[0]:
                self._parse_dialog(trigger, tokens)
            elif "outfit" in tokens[0]:
                self._parse_outfit(trigger, tokens)
            elif "require" in tokens[0]:
                self._parse_require(trigger, tokens)
            elif "payment" in tokens[0]:
                self._parse_payment(trigger, tokens)
            elif "event" in tokens[0]:
                self._parse_event(trigger, tokens)
            elif "fail" in tokens[0]:
                self._parse_fail(trigger, tokens)
            elif "log" in tokens[0] and len(tokens) == 2:
                self._parse_log_type_1(trigger, tokens)
            elif "log" in tokens[0]:
                self._parse_log_type_3(trigger, tokens)
            elif tokens[1] in ["=", "+=", "-="]:
                self._parse_condition_type_0(trigger, tokens)
            elif tokens[1] in ["++", "--"]:
                self._parse_condition_type_1(trigger, tokens)
            elif tokens[0] in ["set", "clear"]:
                self._parse_condition_type_2(trigger, tokens)
            else:
                logging.debug("Trigger component no found: ", self.i,
                              self.line)
            # end if/elif/else

            try:
                nxt = self.get_indent_level(self.mission.lines[self.i + 1])
            except IndexError:
                break
        # end while
        trigger.print_trigger()

    #end _parse_trigger

    def _parse_conversation(self, tokens):
        convo = Conversation()

        if len(tokens) is 2:
            convo.name = tokens[1]

        convo_level = self.get_indent_level(self.line)

        in_convo = True
        while in_convo:
            self.i, self.line = self.enum_lines.__next__()
            self.line = self.line.rstrip()
            convo.lines.append(self.line)

            # check if next line is outside of convo
            try:
                next_line = self.mission.lines[self.i + 1]
                nxt = self.get_indent_level(next_line)
            except IndexError:
                break

            tokens = self.tokenize(next_line)
            if not tokens:
                continue
            if nxt <= convo_level:  # THIS GOES AFTER THE CHECK FOR A NEWLINE BECAUSE THERE ARE NEWLINES AFTER CHOICE
                break
            #if tokens[0] in ["on", "to", "mission", "event", "phrase", "dialog"]:
            #    in_convo = False
        # end while

        self.mission.components.trigger_list[-1].add_convo(convo)

    #end _parse_conversation

    def _parse_dialog(self, trigger, tokens):
        if len(tokens) == 2:
            logging.debug("\t\t\t\tFound Dialog: %s" % tokens[1])
            trigger.dialog = tokens[1]
        else:
            logging.error("COMPLEX DIALOG HANDLING NOT YET IMPLEMENTED")
            cur = self.get_indent_level(self.mission.lines[self.i])
            nxt = self.get_indent_level(self.mission.lines[self.i + 1])
            while True:
                if nxt <= cur:
                    break
                self.i, self.line = self.enum_lines.__next__()

                try:
                    nxt = self.get_indent_level(self.mission.lines[self.i + 1])
                except IndexError:
                    break
            # end while
        # end if/else

    #end _parse_dialog

    def _parse_outfit(self, trigger, tokens):
        logging.debug("\t\t\t\tFound Outfit: %s" % tokens)
        self.store_component_data(trigger.outfit, tokens[1:])

    #end _parse_outfit

    def _parse_require(self, trigger, tokens):
        logging.debug("\t\t\t\tFound Require: %s" % tokens)
        self.store_component_data(trigger.require, tokens[1:])

    #end _parse_require

    def _parse_payment(self, trigger, tokens):
        logging.debug("\t\t\t\tFound Outfit: %s" % tokens)
        trigger.is_payment = True
        self.store_component_data(trigger.payment, tokens[1:])

    #end _parse_payment

    def _parse_event(self, trigger, tokens):
        logging.debug("\t\t\t\tFound Event: %s" % tokens)
        self.store_component_data(trigger.event, tokens[1:])

    #end _parse_event

    @staticmethod
    def _parse_fail(trigger, tokens):
        logging.debug("\t\t\t\tFound Fail: %s" % tokens)
        trigger.is_fail = True
        if len(tokens) == 2:
            trigger.fail = tokens[1]
        else:
            logging.error("COMPLEX FAIL HANDLING NOT YET IMPLEMENTED")
        # end if/else

    #end _parse_fail

    @staticmethod
    def _parse_log_type_1(trigger, tokens):
        logging.debug("\t\t\t\tFound Log: %s" % tokens)
        new_log = trigger.add_log()
        new_log.set(1, tokens[1:])

    #end _parse_log_type_1

    @staticmethod
    def _parse_log_type_3(trigger, tokens):
        logging.debug("\t\t\t\tFound Log: %s" % tokens)
        new_log = trigger.add_log()
        new_log.set(3, tokens[1:])

    #end _parse_log_type_3

    @staticmethod
    def _parse_condition_type_0(trigger, tokens):
        logging.debug("\t\t\t\tFound TriggerCondition: %s" % tokens)
        new_tc = trigger.add_tc()
        new_tc.set(0, tokens)

    #end _parse_condition_type_0

    @staticmethod
    def _parse_condition_type_1(trigger, tokens):
        logging.debug("\t\t\t\tFound TriggerCondition: %s" % tokens)
        new_tc = trigger.add_tc()
        new_tc.set(1, tokens)

    #end _parse_condition_type_1

    @staticmethod
    def _parse_condition_type_2(trigger, tokens):
        logging.debug("\t\t\t\tFound TriggerCondition: %s" % tokens)
        new_tc = trigger.add_tc()
        new_tc.set(2, tokens)

    #end _parse_condition_type_2

    def _parse_condition(self):
        # TODO: Handle these
        cur = self.get_indent_level(self.mission.lines[self.i])
        nxt = self.get_indent_level(self.mission.lines[self.i + 1])
        while True:
            if nxt <= cur:
                break
            self.i, self.line = self.enum_lines.__next__()

            try:
                nxt = self.get_indent_level(self.mission.lines[self.i + 1])
            except IndexError:
                break