Skip to content

Commit

Permalink
Log deprecation of FileWatcher classes in .utils
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Aug 8, 2023
1 parent e51d4d1 commit 8f4674b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions ovos_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")

0 comments on commit 8f4674b

Please sign in to comment.