Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backwards-compat imports with deprecation warnings #209

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions ovos_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,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 @@ -7,14 +7,38 @@
from pyee import BaseEventEmitter

from ovos_utils import create_loop
from ovos_utils.json_helper import merge_dict
from ovos_utils.log import LOG, log_deprecation, deprecated
from ovos_utils.events import EventContainer as _EC
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved

log_deprecation("decode_binary_message, send_binary_file_message, send_binary_data_message, \
send_message, wait_for_reply, listen_once_for_message, get_message_lang, get_websocket, get_mycroft_bus, \
listen_for_message have moved to ovos_bus_client.util", "0.1.0")


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):
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
log_deprecation("Import from `ovos_utils.json_helper`", "0.1.0")
from ovos_utils.json_helper import merge_dict
return merge_dict(*args, **kwargs)


def dig_for_message():
try:
from ovos_bus_client.message import dig_for_message as _dig
Expand Down
2 changes: 1 addition & 1 deletion ovos_utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_BUILD = 37
VERSION_BUILD = "37.post1"
VERSION_ALPHA = 0
# END_VERSION_BLOCK