Beispiel #1
0
    def test_if_file_does_not_exist_it_is_created(self):
        with patch.object(os.path, 'exists', return_value=False):
            with patch.object(json, 'dump') as dump_mock:
                set_setting(self.SETTING_NAME, self.VALUE)

        dump_mock.assert_called_once_with({self.SETTING_NAME: self.VALUE},
                                          self.open_mock())
Beispiel #2
0
    def test_if_file_exists_json_is_updated(self):
        with patch.object(os.path, 'exists', return_value=True):
            with patch.object(json, 'dump') as dump_mock:
                set_setting(self.SETTING_NAME, self.VALUE)

        dump_mock.assert_called_once_with(
            {self.SETTING_NAME: self.VALUE, 'some': 'other'}, self.open_mock()
        )
Beispiel #3
0
    def test_if_file_does_not_exist_it_is_created(self):
        with patch.object(os.path, 'exists', return_value=False):
            with patch.object(json, 'dump') as dump_mock:
                set_setting(self.SETTING_NAME, self.VALUE)

        dump_mock.assert_called_once_with(
            {self.SETTING_NAME: self.VALUE}, self.open_mock()
        )
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 test_if_file_exists_json_is_updated(self):
        with patch.object(os.path, 'exists', return_value=True):
            with patch.object(json, 'dump') as dump_mock:
                set_setting(self.SETTING_NAME, self.VALUE)

        dump_mock.assert_called_once_with(
            {
                self.SETTING_NAME: self.VALUE,
                'some': 'other'
            }, self.open_mock())
Beispiel #6
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 #7
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 #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 _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 #10
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 #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()