(key, new_value)
| 26 | return value |
| 27 | |
| 28 | def 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 |
| 50 | def get_joiner(language): |
no outgoing calls
no test coverage detected