Merge branch 'config' into UI_2.0
This commit is contained in:
12
config.py
12
config.py
@@ -12,11 +12,11 @@ from models.transcription.transcription_languages import transcription_lang
|
|||||||
from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice
|
from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice
|
||||||
|
|
||||||
def saveJson(path, key, value):
|
def saveJson(path, key, value):
|
||||||
with open(path, "r") as fp:
|
with open(path, "r", encoding="utf-8") as fp:
|
||||||
json_data = load(fp)
|
json_data = load(fp)
|
||||||
json_data[key] = value
|
json_data[key] = value
|
||||||
with open(path, "w") as fp:
|
with open(path, "w", encoding="utf-8") as fp:
|
||||||
dump(json_data, fp, indent=4)
|
json_dump(json_data, fp, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
_instance = None
|
_instance = None
|
||||||
@@ -543,13 +543,13 @@ class Config:
|
|||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
if os_path.isfile(self.PATH_CONFIG) is not False:
|
if os_path.isfile(self.PATH_CONFIG) is not False:
|
||||||
with open(self.PATH_CONFIG, 'r') as fp:
|
with open(self.PATH_CONFIG, 'r', encoding="utf-8") as fp:
|
||||||
config = json_load(fp)
|
config = json_load(fp)
|
||||||
|
|
||||||
for key in config.keys():
|
for key in config.keys():
|
||||||
setattr(self, key, config[key])
|
setattr(self, key, config[key])
|
||||||
|
|
||||||
with open(self.PATH_CONFIG, 'w') as fp:
|
with open(self.PATH_CONFIG, 'w', encoding="utf-8") as fp:
|
||||||
setter_methods = [
|
setter_methods = [
|
||||||
name for name, obj in vars(type(self)).items()
|
name for name, obj in vars(type(self)).items()
|
||||||
if isinstance(obj, property) and obj.fset is not None
|
if isinstance(obj, property) and obj.fset is not None
|
||||||
@@ -557,6 +557,6 @@ class Config:
|
|||||||
config = {}
|
config = {}
|
||||||
for method in setter_methods:
|
for method in setter_methods:
|
||||||
config[method] = getattr(self, method)
|
config[method] = getattr(self, method)
|
||||||
json_dump(config, fp, indent=4)
|
json_dump(config, fp, indent=4, ensure_ascii=False)
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
Reference in New Issue
Block a user