Beispiel #1
0
    def _load_engine_list(self):
        self._list_box.Clear()

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for i, engine_data in enumerate(engines):
            self._list_box.Append(engine_data['name'], engine_data)
            if engine_data.get('selected'):
                self._list_box.Select(i)

        self._on_engine_select()
Beispiel #2
0
    def _load_engine_list(self):
        self._list_box.Clear()

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for i, engine_data in enumerate(engines):
            self._list_box.Append(engine_data["name"], engine_data)
            if engine_data.get("selected"):
                self._list_box.Select(i)

        self._on_engine_select()
Beispiel #3
0
    def _on_remove(self, event):
        selected_item = self._list_box.Selection
        if selected_item == -1:
            return

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        del engines[selected_item]
        set_setting(consts.ENGINES_SETTING, engines)

        self._load_engine_list()
Beispiel #4
0
    def _on_remove(self, event):
        selected_item = self._list_box.Selection
        if selected_item == -1:
            return

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        del engines[selected_item]
        set_setting(consts.ENGINES_SETTING, engines)

        self._load_engine_list()
Beispiel #5
0
    def _on_add_engine(self, event):
        dialog = NewEngineDialog()
        dialog.ShowModal()

        if dialog.engine_data:
            engine_list = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
            engine_list.append(dialog.engine_data)
            set_setting(consts.ENGINES_SETTING, engine_list)
            self._load_engine_list()

        dialog.Destroy()
Beispiel #6
0
    def _on_ok(self, event):
        selected_item = self._list_box.Selection

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for index, engine_data in enumerate(engines):
            if index == selected_item:
                engine_data["selected"] = True
            else:
                engine_data.pop("selected", None)
        set_setting(consts.ENGINES_SETTING, engines)

        self.selected_engine = self._selected_engine
        self.Close()
Beispiel #7
0
    def _on_ok(self, event):
        selected_item = self._list_box.Selection

        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for index, engine_data in enumerate(engines):
            if index == selected_item:
                engine_data['selected'] = True
            else:
                engine_data.pop('selected', None)
        set_setting(consts.ENGINES_SETTING, engines)

        self.selected_engine = self._selected_engine
        self.Close()
Beispiel #8
0
    def _on_add_engine(self, event):
        dialog = NewEngineDialog()
        dialog.ShowModal()

        if dialog.engine_data:
            engine_list = get_setting(
                consts.ENGINES_SETTING, consts.DEFAULT_ENGINES
            )
            engine_list.append(dialog.engine_data)
            set_setting(consts.ENGINES_SETTING, engine_list)
            self._load_engine_list()

        dialog.Destroy()
Beispiel #9
0
    def _get_engine_path(self):
        if self._engine_path is not None:
            return self._engine_path

        path = None
        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for engine_data in engines:
            if engine_data.get('selected'):
                path = engine_data['path']
                break

        self._engine_path = path
        return self._engine_path
Beispiel #10
0
    def _get_engine_path(self):
        if self._engine_path is not None:
            return self._engine_path

        path = None
        engines = get_setting(consts.ENGINES_SETTING, consts.DEFAULT_ENGINES)
        for engine_data in engines:
            if engine_data.get('selected'):
                path = engine_data['path']
                break

        self._engine_path = path
        return self._engine_path
Beispiel #11
0
    def _menu_on_open(self, event=None):
        last_directory = get_setting(self.LAST_DIR_SETTING,
                                     os.path.expanduser('~'))
        dialog = wx.FileDialog(self, u'Выберите файл лога', last_directory, '',
                               '*', wx.OPEN)
        if dialog.ShowModal() != wx.ID_OK:
            self.Close()

        filename = dialog.GetPath()
        dialog.Destroy()

        self._log_viever = LogViewer(filename)
        set_setting(self.LAST_DIR_SETTING, os.path.dirname(filename))

        self._menu_on_select_game()
Beispiel #12
0
    def _menu_on_open(self, event=None):
        last_directory = get_setting(
            self.LAST_DIR_SETTING, os.path.expanduser('~')
        )
        dialog = wx.FileDialog(
            self, u'Выберите файл лога', last_directory, '', '*', wx.OPEN
        )
        if dialog.ShowModal() != wx.ID_OK:
            self.Close()

        filename = dialog.GetPath()
        dialog.Destroy()

        self._log_viever = LogViewer(filename)
        set_setting(self.LAST_DIR_SETTING, os.path.dirname(filename))

        self._menu_on_select_game()
Beispiel #13
0
    def test_if_key_exists_in_json_it_is_returned(self):
        with patch.object(os.path, 'exists', return_value=True):
            result = get_setting(self.SETTING_NAME, self.DEFAULT)

        self.assertEqual(result, self.VALUE)
        self.assertTrue(self.open_mock.called)
Beispiel #14
0
    def test_if_file_does_not_exist_default_is_returned(self):
        with patch.object(os.path, 'exists', return_value=False):
            result = get_setting(self.SETTING_NAME, self.DEFAULT)

        self.assertEqual(result, self.DEFAULT)
        self.assertFalse(self.open_mock.called)
Beispiel #15
0
    def test_if_key_exists_in_json_it_is_returned(self):
        with patch.object(os.path, 'exists', return_value=True):
            result = get_setting(self.SETTING_NAME, self.DEFAULT)

        self.assertEqual(result, self.VALUE)
        self.assertTrue(self.open_mock.called)
Beispiel #16
0
    def test_if_key_does_not_exist_in_json_default_is_returned(self):
        with patch.object(os.path, 'exists', return_value=True):
            result = get_setting('another_setting', self.DEFAULT)

        self.assertEqual(result, self.DEFAULT)
        self.assertTrue(self.open_mock.called)
Beispiel #17
0
    def test_if_file_does_not_exist_default_is_returned(self):
        with patch.object(os.path, 'exists', return_value=False):
            result = get_setting(self.SETTING_NAME, self.DEFAULT)

        self.assertEqual(result, self.DEFAULT)
        self.assertFalse(self.open_mock.called)
Beispiel #18
0
    def test_if_key_does_not_exist_in_json_default_is_returned(self):
        with patch.object(os.path, 'exists', return_value=True):
            result = get_setting('another_setting', self.DEFAULT)

        self.assertEqual(result, self.DEFAULT)
        self.assertTrue(self.open_mock.called)