MCPcopy
hub / github.com/Huanshere/VideoLingo / update_key

Function update_key

core/utils/config_utils.py:28–47  ·  view source on GitHub ↗
(key, new_value)

Source from the content-addressed store, hash-verified

26 return value
27
28def update_key(key, new_value):
29 with lock:
30 with open(CONFIG_PATH, 'r', encoding='utf-8') as file:
31 data = yaml.load(file)
32
33 keys = key.split('.')
34 current = data
35 for k in keys[:-1]:
36 if isinstance(current, dict) and k in current:
37 current = current[k]
38 else:
39 return False
40
41 if isinstance(current, dict) and keys[-1] in current:
42 current[keys[-1]] = new_value
43 with open(CONFIG_PATH, 'w', encoding='utf-8') as file:
44 yaml.dump(data, file)
45 return True
46 else:
47 raise KeyError(f"Key '{keys[-1]}' not found in configuration")
48
49# basic utils
50def get_joiner(language):

Callers 10

mainFunction · 0.90
record_and_update_configFunction · 0.90
process_batchFunction · 0.90
config_inputFunction · 0.85
page_settingFunction · 0.85
transcribe_audio_302Function · 0.85
transcribe_audioFunction · 0.85
save_languageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected