From d0934cd6b01ea935a7c53407d7d4a72be3f51a17 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Thu, 7 Mar 2024 23:50:13 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Config=20:=20=E4=B8=AD?= =?UTF-8?q?=E5=9B=BD=E8=AA=9E=E8=A1=A8=E8=A8=98=E5=A4=89=E6=9B=B4=E3=81=AB?= =?UTF-8?q?=E4=BC=B4=E3=81=84=E3=80=81config=E8=A8=AD=E5=AE=9A=E5=80=A4?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E3=81=AA=E5=80=A4=E3=81=8C=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E3=81=9F=E3=82=81=E6=97=A2=E5=AD=98?= =?UTF-8?q?config.json=E3=81=A7=E8=B5=B7=E5=8B=95=E3=81=97=E3=81=9F?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AB=E7=89=B9=E5=AE=9A=E4=BE=9D=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=83=97=E3=83=AD=E3=82=B0=E3=83=A9=E3=83=A0=E3=81=8C?= =?UTF-8?q?=E8=B5=B7=E5=8B=95=E3=81=97=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 772773af..6bb0f4c5 100644 --- a/config.py +++ b/config.py @@ -7,6 +7,7 @@ import tkinter as tk from tkinter import font from models.translation.translation_languages import translation_lang from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice +from models.transcription.transcription_languages import transcription_lang from utils import generatePercentageStringsList, isUniqueStrings json_serializable_vars = {} @@ -289,7 +290,13 @@ class Config: @SELECTED_TAB_YOUR_LANGUAGES.setter def SELECTED_TAB_YOUR_LANGUAGES(self, value): if isinstance(value, dict): - self._SELECTED_TAB_YOUR_LANGUAGES = value + try: + for k, v in value.items(): + if k not in list(transcription_lang.keys()) or v not in list(transcription_lang[k].keys()): + raise ValueError + self._SELECTED_TAB_YOUR_LANGUAGES = value + except ValueError: + pass saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property @@ -300,7 +307,13 @@ class Config: @SELECTED_TAB_TARGET_LANGUAGES.setter def SELECTED_TAB_TARGET_LANGUAGES(self, value): if isinstance(value, dict): - self._SELECTED_TAB_TARGET_LANGUAGES = value + try: + for k, v in value.items(): + if k not in list(transcription_lang.keys()) or v not in list(transcription_lang[k].keys()): + raise ValueError + self._SELECTED_TAB_TARGET_LANGUAGES = value + except ValueError: + pass saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property