Skip to content

Commit

Permalink
Add backwards-compat imports with deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Dec 29, 2023
1 parent 2df4248 commit 938e9a6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
18 changes: 5 additions & 13 deletions ovos_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,11 @@ def wait_for_exit_signal():
LOG.debug(f"Exiting on KeyboardInterrupt")


def get_handler_name(handler):
"""Name (including class if available) of handler function.
Arguments:
handler (function): Function to be named
Returns:
string: handler name as string
"""
if '__self__' in dir(handler) and 'name' in dir(handler.__self__):
return handler.__self__.name + '.' + handler.__name__
else:
return handler.__name__
def get_handler_name(*args, **kwargs):
from ovos_utils.log import log_deprecation
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
from ovos_utils.events import get_handler_name
return get_handler_name(*args, **kwargs)


def camel_case_split(identifier: str) -> str:
Expand Down
26 changes: 25 additions & 1 deletion ovos_utils/messagebus.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@

from pyee import BaseEventEmitter

from ovos_utils.json_helper import merge_dict
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.events import EventContainer as _EC


class EventContainer(_EC):
def __init__(self, bus=None):
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
_EC.__init__(self, bus=bus)


def create_wrapper(*args, **kwargs):
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
from ovos_utils.events import create_wrapper
return create_wrapper(*args, **kwargs)


def get_handler_name(*args, **kwargs):
log_deprecation("Import from `ovos_utils.events`", "0.1.0")
from ovos_utils.events import get_handler_name
return get_handler_name(*args, **kwargs)


def merge_dict(*args, **kwargs):
log_deprecation("Import from `ovos_utils.json_helper`", "0.1.0")
from ovos_utils.json_helper import merge_dict
return get_handler_name(*args, **kwargs)


def dig_for_message():
Expand Down

0 comments on commit 938e9a6

Please sign in to comment.