Skip to content

Commit

Permalink
better deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jan 11, 2025
1 parent ec0702a commit e1e82c9
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions ovos_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from os.path import isfile
from typing import Optional

from ovos_config.locations import get_xdg_config_locations
from ovos_config.locations import get_xdg_config_locations, ASSISTANT_CONFIG, USER_CONFIG
from ovos_config.models import LocalConf, DefaultConfig, \
DistributionConfig, SystemConfig, RemoteConf, AssistantConfig

Expand Down Expand Up @@ -371,6 +371,20 @@ def clear_cache(message=None):
Configuration.updated(message)


def update_assistant_config(config, bus=None):
f""" updates assistant config file with the contents of provided dict
path: {ASSISTANT_CONFIG}
"""
conf = AssistantConfig()
conf.merge(config)
conf.store()
if bus: # inform all Configuration objects connected to the bus
# imported from ovos_utils to allow FakeMessage if ovos-bus-client is missing
from ovos_utils.fakebus import Message
bus.emit(Message("configuration.patch", {"config": config}))
return conf


def read_mycroft_config():
""" returns a stateless dict with the loaded configuration """
warnings.warn(
Expand All @@ -384,14 +398,10 @@ def read_mycroft_config():
def update_mycroft_config(config, path=None, bus=None):
""" updates user config file with the contents of provided dict
if a path is provided that location will be used instead of AssistantConfig"""
if path is None:
conf = AssistantConfig()
else:
conf = LocalConf(path)
conf.merge(config)
conf.store()
if bus: # inform all Configuration objects connected to the bus
# imported from ovos_utils to allow FakeMessage if ovos-bus-client is missing
from ovos_utils.fakebus import Message
bus.emit(Message("configuration.patch", {"config": config}))
return conf
warnings.warn(
"use 'update_assistant_config' instead",
DeprecationWarning,
stacklevel=2,
)
LOG.warning(f"Updating '{ASSISTANT_CONFIG}' NOT '{path or USER_CONFIG}'")
return update_assistant_config(config, bus)

0 comments on commit e1e82c9

Please sign in to comment.