diff --git a/ovos_config/utils.py b/ovos_config/utils.py index 2ebde93..b9373b1 100644 --- a/ovos_config/utils.py +++ b/ovos_config/utils.py @@ -2,12 +2,19 @@ import importlib from typing import Optional -from ovos_utils.log import LOG +from ovos_utils.log import LOG, log_deprecation from os import makedirs from os.path import join, dirname from ovos_utils.xdg_utils import xdg_config_home -# backwards compat -from ovos_utils.file_utils import FileWatcher, FileEventHandler + +try: + # TODO: Consider deprecating these before 0.1.0 + from ovos_utils.file_utils import FileWatcher as _FileWatcher, \ + FileEventHandler as _FileEventHandler +except ImportError: + LOG.debug("Failed to import `FileWatcher` and `FileEventHandler`") + _FileWatcher = None + _FileEventHandler = None def init_module_config(module_name: str, module_override: str, @@ -83,3 +90,19 @@ def init_module_config(module_name: str, module_override: str, importlib.reload(ovos_config.models) importlib.reload(ovos_config.config) importlib.reload(ovos_config) + + +class FileWatcher(_FileWatcher): + def __init__(self, *args, **kwargs): + if _FileWatcher is None: + raise ImportError("Import from ovos_utils.file_utils directly") + _FileWatcher.__init__(self, *args, **kwargs) + log_deprecation("Import from ovos_utils.file_utils directly", "0.1.0") + + +class FileEventHandler(_FileEventHandler): + def __init__(self, *args, **kwargs): + if _FileEventHandler is None: + raise ImportError("Import from ovos_utils.file_utils directly") + _FileEventHandler.__init__(self, *args, **kwargs) + log_deprecation("Import from ovos_utils.file_utils directly", "0.1.0")