From d3a6bb07ad9ced2f6113466c6d8e025c4d87a6fd Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:06:08 -0700 Subject: [PATCH] Log deprecation of FileWatcher classes in `.utils` (#64) --- ovos_config/utils.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) 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")