📝[Refactor] ruffを使用しコード検証修正を行った
This commit is contained in:
72
config.py
72
config.py
@@ -70,7 +70,7 @@ class Config:
|
||||
|
||||
@ENABLE_TRANSLATION.setter
|
||||
def ENABLE_TRANSLATION(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_TRANSLATION = value
|
||||
|
||||
@property
|
||||
@@ -79,7 +79,7 @@ class Config:
|
||||
|
||||
@ENABLE_TRANSCRIPTION_SEND.setter
|
||||
def ENABLE_TRANSCRIPTION_SEND(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_TRANSCRIPTION_SEND = value
|
||||
|
||||
@property
|
||||
@@ -88,7 +88,7 @@ class Config:
|
||||
|
||||
@ENABLE_TRANSCRIPTION_RECEIVE.setter
|
||||
def ENABLE_TRANSCRIPTION_RECEIVE(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_TRANSCRIPTION_RECEIVE = value
|
||||
|
||||
@property
|
||||
@@ -97,7 +97,7 @@ class Config:
|
||||
|
||||
@ENABLE_FOREGROUND.setter
|
||||
def ENABLE_FOREGROUND(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_FOREGROUND = value
|
||||
|
||||
@property
|
||||
@@ -106,7 +106,7 @@ class Config:
|
||||
|
||||
@SOURCE_COUNTRY.setter
|
||||
def SOURCE_COUNTRY(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._SOURCE_COUNTRY = value
|
||||
|
||||
@property
|
||||
@@ -115,7 +115,7 @@ class Config:
|
||||
|
||||
@SOURCE_LANGUAGE.setter
|
||||
def SOURCE_LANGUAGE(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._SOURCE_LANGUAGE = value
|
||||
|
||||
@property
|
||||
@@ -124,7 +124,7 @@ class Config:
|
||||
|
||||
@TARGET_COUNTRY.setter
|
||||
def TARGET_COUNTRY(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._TARGET_COUNTRY = value
|
||||
|
||||
@property
|
||||
@@ -133,7 +133,7 @@ class Config:
|
||||
|
||||
@TARGET_LANGUAGE.setter
|
||||
def TARGET_LANGUAGE(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._TARGET_LANGUAGE = value
|
||||
|
||||
@property
|
||||
@@ -154,7 +154,7 @@ class Config:
|
||||
|
||||
@SELECTED_TAB_NO.setter
|
||||
def SELECTED_TAB_NO(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._SELECTED_TAB_NO = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -165,7 +165,7 @@ class Config:
|
||||
|
||||
@SELECTED_TAB_YOUR_LANGUAGES.setter
|
||||
def SELECTED_TAB_YOUR_LANGUAGES(self, value):
|
||||
if type(value) is dict:
|
||||
if isinstance(value, dict):
|
||||
self._SELECTED_TAB_YOUR_LANGUAGES = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -176,7 +176,7 @@ class Config:
|
||||
|
||||
@SELECTED_TAB_TARGET_LANGUAGES.setter
|
||||
def SELECTED_TAB_TARGET_LANGUAGES(self, value):
|
||||
if type(value) is dict:
|
||||
if isinstance(value, dict):
|
||||
self._SELECTED_TAB_TARGET_LANGUAGES = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -187,7 +187,7 @@ class Config:
|
||||
|
||||
@IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE.setter
|
||||
def IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -199,7 +199,7 @@ class Config:
|
||||
|
||||
@TRANSPARENCY.setter
|
||||
def TRANSPARENCY(self, value):
|
||||
if type(value) is int and 0 <= value <= 100:
|
||||
if isinstance(value, int) and 0 <= value <= 100:
|
||||
self._TRANSPARENCY = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -232,7 +232,7 @@ class Config:
|
||||
|
||||
@TEXTBOX_UI_SCALING.setter
|
||||
def TEXTBOX_UI_SCALING(self, value):
|
||||
if type(value) is int and 50 <= value <= 200:
|
||||
if isinstance(value, int) and 50 <= value <= 200:
|
||||
self._TEXTBOX_UI_SCALING = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -290,7 +290,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_ENERGY_THRESHOLD.setter
|
||||
def INPUT_MIC_ENERGY_THRESHOLD(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_MIC_ENERGY_THRESHOLD = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -301,7 +301,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD.setter
|
||||
def INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -312,7 +312,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_RECORD_TIMEOUT.setter
|
||||
def INPUT_MIC_RECORD_TIMEOUT(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_MIC_RECORD_TIMEOUT = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -323,7 +323,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_PHRASE_TIMEOUT.setter
|
||||
def INPUT_MIC_PHRASE_TIMEOUT(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_MIC_PHRASE_TIMEOUT = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -334,7 +334,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_MAX_PHRASES.setter
|
||||
def INPUT_MIC_MAX_PHRASES(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_MIC_MAX_PHRASES = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -345,7 +345,7 @@ class Config:
|
||||
|
||||
@INPUT_MIC_WORD_FILTER.setter
|
||||
def INPUT_MIC_WORD_FILTER(self, value):
|
||||
if type(value) is list:
|
||||
if isinstance(value, list):
|
||||
self._INPUT_MIC_WORD_FILTER = sorted(set(value), key=value.index)
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -356,7 +356,7 @@ class Config:
|
||||
|
||||
@INPUT_SPEAKER_ENERGY_THRESHOLD.setter
|
||||
def INPUT_SPEAKER_ENERGY_THRESHOLD(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_SPEAKER_ENERGY_THRESHOLD = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -367,7 +367,7 @@ class Config:
|
||||
|
||||
@INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD.setter
|
||||
def INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -378,7 +378,7 @@ class Config:
|
||||
|
||||
@INPUT_SPEAKER_RECORD_TIMEOUT.setter
|
||||
def INPUT_SPEAKER_RECORD_TIMEOUT(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_SPEAKER_RECORD_TIMEOUT = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -389,7 +389,7 @@ class Config:
|
||||
|
||||
@INPUT_SPEAKER_PHRASE_TIMEOUT.setter
|
||||
def INPUT_SPEAKER_PHRASE_TIMEOUT(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_SPEAKER_PHRASE_TIMEOUT = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -400,7 +400,7 @@ class Config:
|
||||
|
||||
@INPUT_SPEAKER_MAX_PHRASES.setter
|
||||
def INPUT_SPEAKER_MAX_PHRASES(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._INPUT_SPEAKER_MAX_PHRASES = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -411,7 +411,7 @@ class Config:
|
||||
|
||||
@OSC_IP_ADDRESS.setter
|
||||
def OSC_IP_ADDRESS(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._OSC_IP_ADDRESS = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -422,7 +422,7 @@ class Config:
|
||||
|
||||
@OSC_PORT.setter
|
||||
def OSC_PORT(self, value):
|
||||
if type(value) is int:
|
||||
if isinstance(value, int):
|
||||
self._OSC_PORT = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -433,9 +433,9 @@ class Config:
|
||||
|
||||
@AUTH_KEYS.setter
|
||||
def AUTH_KEYS(self, value):
|
||||
if type(value) is dict and set(value.keys()) == set(self.AUTH_KEYS.keys()):
|
||||
if isinstance(value, dict) and set(value.keys()) == set(self.AUTH_KEYS.keys()):
|
||||
for key, value in value.items():
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
self._AUTH_KEYS[key] = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.AUTH_KEYS)
|
||||
|
||||
@@ -446,7 +446,7 @@ class Config:
|
||||
|
||||
@MESSAGE_FORMAT.setter
|
||||
def MESSAGE_FORMAT(self, value):
|
||||
if type(value) is str:
|
||||
if isinstance(value, str):
|
||||
if isUniqueStrings(["[message]", "[translation]"], value) is False:
|
||||
value = "[message]([translation])"
|
||||
self._MESSAGE_FORMAT = value
|
||||
@@ -459,7 +459,7 @@ class Config:
|
||||
|
||||
@ENABLE_AUTO_CLEAR_MESSAGE_BOX.setter
|
||||
def ENABLE_AUTO_CLEAR_MESSAGE_BOX(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_AUTO_CLEAR_MESSAGE_BOX = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -470,7 +470,7 @@ class Config:
|
||||
|
||||
@ENABLE_NOTICE_XSOVERLAY.setter
|
||||
def ENABLE_NOTICE_XSOVERLAY(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_NOTICE_XSOVERLAY = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -481,7 +481,7 @@ class Config:
|
||||
|
||||
@ENABLE_SEND_MESSAGE_TO_VRC.setter
|
||||
def ENABLE_SEND_MESSAGE_TO_VRC(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_SEND_MESSAGE_TO_VRC = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -493,7 +493,7 @@ class Config:
|
||||
|
||||
# @STARTUP_OSC_ENABLED_CHECK.setter
|
||||
# def STARTUP_OSC_ENABLED_CHECK(self, value):
|
||||
# if type(value) is bool:
|
||||
# if isinstance(value, bool):
|
||||
# self._STARTUP_OSC_ENABLED_CHECK = value
|
||||
# saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -504,7 +504,7 @@ class Config:
|
||||
|
||||
@ENABLE_LOGGER.setter
|
||||
def ENABLE_LOGGER(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._ENABLE_LOGGER = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
@@ -515,7 +515,7 @@ class Config:
|
||||
|
||||
@IS_CONFIG_WINDOW_COMPACT_MODE.setter
|
||||
def IS_CONFIG_WINDOW_COMPACT_MODE(self, value):
|
||||
if type(value) is bool:
|
||||
if isinstance(value, bool):
|
||||
self._IS_CONFIG_WINDOW_COMPACT_MODE = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def sendMicMessage(message):
|
||||
pass
|
||||
else:
|
||||
translation = model.getInputTranslate(message)
|
||||
if translation == False:
|
||||
if translation is False:
|
||||
config.ENABLE_TRANSLATION = False
|
||||
translation = ""
|
||||
view.translationEngineLimitErrorProcess()
|
||||
@@ -94,7 +94,7 @@ def receiveSpeakerMessage(message):
|
||||
pass
|
||||
else:
|
||||
translation = model.getOutputTranslate(message)
|
||||
if translation == False:
|
||||
if translation is False:
|
||||
config.ENABLE_TRANSLATION = False
|
||||
translation = ""
|
||||
view.translationEngineLimitErrorProcess()
|
||||
@@ -160,7 +160,7 @@ def sendChatMessage(message):
|
||||
pass
|
||||
else:
|
||||
translation = model.getInputTranslate(message)
|
||||
if translation == False:
|
||||
if translation is False:
|
||||
config.ENABLE_TRANSLATION = False
|
||||
translation = ""
|
||||
view.translationEngineLimitErrorProcess()
|
||||
@@ -426,7 +426,8 @@ def callbackSetMicDevice(value):
|
||||
|
||||
def callbackSetMicEnergyThreshold(value):
|
||||
print("callbackSetMicEnergyThreshold", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value <= config.MAX_MIC_ENERGY_THRESHOLD:
|
||||
@@ -435,7 +436,7 @@ def callbackSetMicEnergyThreshold(value):
|
||||
view.setGuiVariable_MicEnergyThreshold(config.INPUT_MIC_ENERGY_THRESHOLD)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_MicEnergyThreshold()
|
||||
|
||||
def callbackSetMicDynamicEnergyThreshold(value):
|
||||
@@ -462,7 +463,8 @@ def callbackCheckMicThreshold(is_turned_on):
|
||||
|
||||
def callbackSetMicRecordTimeout(value):
|
||||
print("callbackSetMicRecordTimeout", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value <= config.INPUT_MIC_PHRASE_TIMEOUT:
|
||||
@@ -471,12 +473,13 @@ def callbackSetMicRecordTimeout(value):
|
||||
view.setGuiVariable_MicRecordTimeout(config.INPUT_MIC_RECORD_TIMEOUT)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_MicRecordTimeout()
|
||||
|
||||
def callbackSetMicPhraseTimeout(value):
|
||||
print("callbackSetMicPhraseTimeout", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value >= config.INPUT_MIC_RECORD_TIMEOUT:
|
||||
@@ -485,12 +488,13 @@ def callbackSetMicPhraseTimeout(value):
|
||||
view.setGuiVariable_MicPhraseTimeout(config.INPUT_MIC_PHRASE_TIMEOUT)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_MicPhraseTimeout()
|
||||
|
||||
def callbackSetMicMaxPhrases(value):
|
||||
print("callbackSetMicMaxPhrases", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value:
|
||||
@@ -499,7 +503,7 @@ def callbackSetMicMaxPhrases(value):
|
||||
view.setGuiVariable_MicMaxPhrases(config.INPUT_MIC_MAX_PHRASES)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_MicMaxPhrases()
|
||||
|
||||
def callbackSetMicWordFilter(values):
|
||||
@@ -532,13 +536,14 @@ def callbackDeleteMicWordFilter(value):
|
||||
new_input_mic_word_filter_list.remove(str(value))
|
||||
config.INPUT_MIC_WORD_FILTER = new_input_mic_word_filter_list
|
||||
view.setLatestConfigVariable("MicMicWordFilter")
|
||||
except:
|
||||
except Exception:
|
||||
print("There was no the target word in config.INPUT_MIC_WORD_FILTER")
|
||||
|
||||
|
||||
def callbackSetSpeakerEnergyThreshold(value):
|
||||
print("callbackSetSpeakerEnergyThreshold", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value <= config.MAX_SPEAKER_ENERGY_THRESHOLD:
|
||||
@@ -547,7 +552,7 @@ def callbackSetSpeakerEnergyThreshold(value):
|
||||
view.setGuiVariable_SpeakerEnergyThreshold(config.INPUT_SPEAKER_ENERGY_THRESHOLD)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_SpeakerEnergyThreshold()
|
||||
|
||||
def callbackSetSpeakerDynamicEnergyThreshold(value):
|
||||
@@ -580,7 +585,8 @@ def callbackCheckSpeakerThreshold(is_turned_on):
|
||||
|
||||
def callbackSetSpeakerRecordTimeout(value):
|
||||
print("callbackSetSpeakerRecordTimeout", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value <= config.INPUT_SPEAKER_PHRASE_TIMEOUT:
|
||||
@@ -589,12 +595,13 @@ def callbackSetSpeakerRecordTimeout(value):
|
||||
view.setGuiVariable_SpeakerRecordTimeout(config.INPUT_SPEAKER_RECORD_TIMEOUT)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_SpeakerRecordTimeout()
|
||||
|
||||
def callbackSetSpeakerPhraseTimeout(value):
|
||||
print("callbackSetSpeakerPhraseTimeout", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value and value >= config.INPUT_SPEAKER_RECORD_TIMEOUT:
|
||||
@@ -603,12 +610,13 @@ def callbackSetSpeakerPhraseTimeout(value):
|
||||
view.setGuiVariable_SpeakerPhraseTimeout(config.INPUT_SPEAKER_PHRASE_TIMEOUT)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_SpeakerPhraseTimeout()
|
||||
|
||||
def callbackSetSpeakerMaxPhrases(value):
|
||||
print("callbackSetSpeakerMaxPhrases", value)
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
try:
|
||||
value = int(value)
|
||||
if 0 <= value:
|
||||
@@ -617,7 +625,7 @@ def callbackSetSpeakerMaxPhrases(value):
|
||||
view.setGuiVariable_SpeakerMaxPhrases(config.INPUT_SPEAKER_MAX_PHRASES)
|
||||
else:
|
||||
raise ValueError()
|
||||
except:
|
||||
except Exception:
|
||||
view.showErrorMessage_SpeakerMaxPhrases()
|
||||
|
||||
|
||||
@@ -662,12 +670,14 @@ def callbackSetEnableSendMessageToVrc(value):
|
||||
|
||||
# Advanced Settings Tab
|
||||
def callbackSetOscIpAddress(value):
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
print("callbackSetOscIpAddress", str(value))
|
||||
config.OSC_IP_ADDRESS = str(value)
|
||||
|
||||
def callbackSetOscPort(value):
|
||||
if value == "": return
|
||||
if value == "":
|
||||
return
|
||||
print("callbackSetOscPort", int(value))
|
||||
config.OSC_PORT = int(value)
|
||||
|
||||
|
||||
2
main.py
2
main.py
@@ -12,7 +12,7 @@ if __name__ == "__main__":
|
||||
splash.destroySplash()
|
||||
controller.showMainWindow()
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
import traceback
|
||||
with open('error.log', 'a') as f:
|
||||
traceback.print_exc(file=f)
|
||||
26
model.py
26
model.py
@@ -82,9 +82,9 @@ class Model:
|
||||
self.keyword_processor = KeywordProcessor()
|
||||
|
||||
def authenticationTranslator(self, choice_translator=None, auth_key=None):
|
||||
if choice_translator == None:
|
||||
if choice_translator is None:
|
||||
choice_translator = config.CHOICE_TRANSLATOR
|
||||
if auth_key == None:
|
||||
if auth_key is None:
|
||||
auth_key = config.AUTH_KEYS[choice_translator]
|
||||
|
||||
result = self.translator.authentication(choice_translator, auth_key)
|
||||
@@ -130,10 +130,10 @@ class Model:
|
||||
compatible_engines.append(engine)
|
||||
engine_name = compatible_engines[0]
|
||||
|
||||
if engine_name == "DeepL" and config.AUTH_KEYS["DeepL_API"] != None:
|
||||
if engine_name == "DeepL" and config.AUTH_KEYS["DeepL_API"] is not None:
|
||||
if self.authenticationTranslator(engine_name, config.AUTH_KEYS["DeepL_API"]) is True:
|
||||
engine_name = "DeepL_API"
|
||||
elif engine_name == "DeepL_API" and config.AUTH_KEYS["DeepL_API"] == None:
|
||||
elif engine_name == "DeepL_API" and config.AUTH_KEYS["DeepL_API"] is None:
|
||||
engine_name = "DeepL"
|
||||
|
||||
return engine_name
|
||||
@@ -288,7 +288,7 @@ class Model:
|
||||
rmtree(os_path.join(current_directory, tmp_directory_name))
|
||||
command = [os_path.join(program_directory, "batch", batch_name), program_name, temporary_name, str(restart)]
|
||||
Popen(command)
|
||||
except:
|
||||
except Exception:
|
||||
webbrowser.open(config.BOOTH_URL, new=2, autoraise=True)
|
||||
|
||||
@staticmethod
|
||||
@@ -319,7 +319,7 @@ class Model:
|
||||
if config.CHOICE_MIC_HOST == "NoHost" or config.CHOICE_MIC_DEVICE == "NoDevice":
|
||||
try:
|
||||
error_fnc()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
@@ -348,7 +348,7 @@ class Model:
|
||||
message = mic_transcriber.getTranscript()
|
||||
try:
|
||||
fnc(message)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.mic_print_transcript = threadFnc(sendMicTranscript)
|
||||
@@ -367,7 +367,7 @@ class Model:
|
||||
if config.CHOICE_MIC_HOST == "NoHost" or config.CHOICE_MIC_DEVICE == "NoDevice":
|
||||
try:
|
||||
error_fnc()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
@@ -376,7 +376,7 @@ class Model:
|
||||
energy = mic_energy_queue.get()
|
||||
try:
|
||||
fnc(energy)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
sleep(0.01)
|
||||
|
||||
@@ -401,7 +401,7 @@ class Model:
|
||||
if speaker_device["name"] == "NoDevice":
|
||||
try:
|
||||
error_fnc()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
@@ -429,7 +429,7 @@ class Model:
|
||||
message = speaker_transcriber.getTranscript()
|
||||
try:
|
||||
fnc(message)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.speaker_print_transcript = threadFnc(sendSpeakerTranscript)
|
||||
@@ -449,7 +449,7 @@ class Model:
|
||||
if speaker_device["name"] == "NoDevice":
|
||||
try:
|
||||
error_fnc()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
@@ -458,7 +458,7 @@ class Model:
|
||||
energy = speaker_energy_queue.get()
|
||||
try:
|
||||
fnc(energy)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
sleep(0.01)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from time import sleep
|
||||
from typing import List
|
||||
from pythonosc import osc_message_builder
|
||||
from pythonosc import udp_client
|
||||
from pythonosc import dispatcher
|
||||
@@ -15,7 +14,7 @@ def sendTyping(flag=False, ip_address="127.0.0.1", port=9000):
|
||||
|
||||
# send OSC message
|
||||
def sendMessage(message=None, ip_address="127.0.0.1", port=9000):
|
||||
if message != None:
|
||||
if message is not None:
|
||||
msg = osc_message_builder.OscMessageBuilder(address="/chatbox/input")
|
||||
msg.add_arg(f"{message}")
|
||||
msg.add_arg(True)
|
||||
|
||||
@@ -38,7 +38,7 @@ class AudioTranscriber:
|
||||
# os.close(fd)
|
||||
audio_data = self.audio_sources["process_data_func"]()
|
||||
text = self.audio_recognizer.recognize_google(audio_data, language=transcription_lang[language][country])
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
pass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from deepl import Translator as deepl_Translator
|
||||
from deepl_translate import translate as deepl_web_Translator
|
||||
from translators import translate_text as other_web_Translator
|
||||
from .translation_languages import translatorEngine, translation_lang
|
||||
from .translation_languages import translation_lang
|
||||
|
||||
# Translator
|
||||
class Translator():
|
||||
@@ -16,7 +16,7 @@ class Translator():
|
||||
try:
|
||||
self.deepl_client = deepl_Translator(authkey)
|
||||
self.deepl_client.translate_text(" ", target_lang="EN-US")
|
||||
except:
|
||||
except Exception:
|
||||
result = False
|
||||
return result
|
||||
|
||||
@@ -52,7 +52,7 @@ class Translator():
|
||||
from_language=source_language,
|
||||
to_language=target_language,
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
import traceback
|
||||
with open('error.log', 'a') as f:
|
||||
traceback.print_exc(file=f)
|
||||
|
||||
@@ -33,7 +33,7 @@ def XSOverlay(
|
||||
with open(icon, "rb") as f:
|
||||
icon_data_bytes = f.read()
|
||||
icon_data = base64.b64encode(icon_data_bytes).decode("utf-8")
|
||||
except:
|
||||
except Exception:
|
||||
icon_data = "default"
|
||||
else:
|
||||
icon_data = icon
|
||||
|
||||
3
utils.py
3
utils.py
@@ -13,7 +13,8 @@ def get_key_by_value(dictionary, value):
|
||||
return None
|
||||
|
||||
def callFunctionIfCallable(function, *args):
|
||||
if callable(function) is True: function(*args)
|
||||
if callable(function) is True:
|
||||
function(*args)
|
||||
|
||||
def isEven(number):
|
||||
return number % 2 == 0
|
||||
|
||||
@@ -233,7 +233,8 @@ class _CreateConfirmationModal(CTkToplevel):
|
||||
self.grab_release()
|
||||
|
||||
def focusOutFunction(self, e):
|
||||
if str(e.widget) != ".!_createconfirmationmodal": return
|
||||
if str(e.widget) != ".!_createconfirmationmodal":
|
||||
return
|
||||
callFunctionIfCallable(self._view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL)
|
||||
|
||||
def _grab_set(self):
|
||||
|
||||
@@ -262,7 +262,8 @@ class _CreateDropdownMenuWindow(CTkToplevel):
|
||||
|
||||
|
||||
def show(self, dropdown_menu_widget_id):
|
||||
if self.hide is False: return
|
||||
if self.hide is False:
|
||||
return
|
||||
self.wm_attributes("-alpha", 0)
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ class _CreateErrorWindow(CTkToplevel):
|
||||
|
||||
|
||||
def show(self, target_widget):
|
||||
if self.hide is False: return
|
||||
if self.hide is False:
|
||||
return
|
||||
|
||||
self.attach_widget = target_widget
|
||||
|
||||
|
||||
@@ -178,5 +178,6 @@ class _CreateSelectableLanguagesWindow(CTkToplevel):
|
||||
|
||||
|
||||
def focusOutFunction(self, e):
|
||||
if str(e.widget) != ".!_createselectablelanguageswindow": return
|
||||
if str(e.widget) != ".!_createselectablelanguageswindow":
|
||||
return
|
||||
self.vrct_gui._closeSelectableLanguagesWindow()
|
||||
@@ -2,7 +2,7 @@ from functools import partial
|
||||
from types import SimpleNamespace
|
||||
from typing import Union
|
||||
|
||||
from customtkinter import CTkOptionMenu, CTkFont, CTkFrame, CTkLabel, CTkRadioButton, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage
|
||||
from CTkToolTip import *
|
||||
|
||||
from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox, getLatestHeight, bindButtonFunctionAndColor
|
||||
@@ -1068,7 +1068,8 @@ class _SettingBoxGenerator():
|
||||
items[i] = item_data
|
||||
is_replaced = True
|
||||
break
|
||||
if is_replaced is False: items.append(item_data)
|
||||
if is_replaced is False:
|
||||
items.append(item_data)
|
||||
|
||||
|
||||
return mic_word_filter_item_wrapper
|
||||
|
||||
@@ -2,7 +2,7 @@ from functools import partial
|
||||
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkSwitch, CTkImage
|
||||
|
||||
from ....ui_utils import openImageKeepAspectRatio, retag, getLatestHeight, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressAndReleaseFunction
|
||||
from ....ui_utils import openImageKeepAspectRatio, retag, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressAndReleaseFunction
|
||||
|
||||
from utils import callFunctionIfCallable
|
||||
|
||||
|
||||
@@ -162,10 +162,12 @@ def createOptionMenuBox(parent_widget, optionmenu_bg_color, optionmenu_hovered_b
|
||||
option_menu_box = CTkFrame(parent_widget, corner_radius=6, fg_color=optionmenu_bg_color, cursor="hand2")
|
||||
|
||||
option_menu_box.grid_rowconfigure(0, weight=1)
|
||||
if optionmenu_min_height is not None: option_menu_box.grid_rowconfigure(0, minsize=optionmenu_min_height)
|
||||
if optionmenu_min_height is not None:
|
||||
option_menu_box.grid_rowconfigure(0, minsize=optionmenu_min_height)
|
||||
|
||||
option_menu_box.grid_columnconfigure(0, weight=1)
|
||||
if optionmenu_min_width is not None: option_menu_box.grid_columnconfigure(0, minsize=optionmenu_min_width)
|
||||
if optionmenu_min_width is not None:
|
||||
option_menu_box.grid_columnconfigure(0, minsize=optionmenu_min_width)
|
||||
|
||||
optionmenu_label_wrapper = CTkFrame(option_menu_box, corner_radius=0, fg_color=optionmenu_bg_color)
|
||||
optionmenu_label_wrapper.grid(row=0, column=0, padx=(optionmenu_ipadx[0],0), pady=optionmenu_ipady, sticky="ew")
|
||||
|
||||
@@ -269,7 +269,7 @@ class VRCT_GUI(CTk):
|
||||
def _clearErrorMessage(self):
|
||||
try:
|
||||
self.error_message_window._withdraw()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user