Skip to content

Commit

Permalink
Add backwards-compat imports with deprecation warnings (OpenVoiceOS#209)
Browse files Browse the repository at this point in the history
* Add backwards-compat imports with deprecation warnings
NeonGeckoCom/NeonCore#599

* Fix `merge_dict` override

* Specify post release version

* 0.0.32post1 (OpenVoiceOS#210)

* less deprecation warning logs

* restore EventContainer deprecation log

---------

Co-authored-by: Daniel McKnight <[email protected]>
Co-authored-by: JarbasAI <[email protected]>
  • Loading branch information
3 people authored and emphasize committed Dec 30, 2023
1 parent f88d486 commit d1cdc81
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 421 deletions.
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
2 changes: 1 addition & 1 deletion ovos_utils/enclosure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ovos_bus_client.apis.enclosure import EnclosureApi

except ImportError:
from ovos_utils.messagebus import FakeMessage as Message, dig_for_message
from ovos_utils.fakebus import Message, dig_for_message

class EnclosureAPI:
"""
Expand Down
12 changes: 6 additions & 6 deletions ovos_utils/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from inspect import signature
from typing import Callable, Optional, Union

import ovos_utils.messagebus
from ovos_utils.intents.intent_service_interface import to_alnum
from ovos_utils.fakebus import Message, FakeBus, dig_for_message
from ovos_utils.file_utils import to_alnum
from ovos_utils.log import LOG, log_deprecation, deprecated


Expand All @@ -17,7 +17,7 @@ def unmunge_message(message, skill_id: str):
Returns:
Message without clear keywords
"""
if isinstance(message, ovos_utils.messagebus.Message) and \
if isinstance(message, Message) and \
isinstance(message.data, dict):
skill_id = to_alnum(skill_id)
for key in list(message.data.keys()):
Expand Down Expand Up @@ -131,7 +131,7 @@ class EventContainer:
"""

def __init__(self, bus=None):
self.bus = bus or ovos_utils.messagebus.FakeBus()
self.bus = bus or FakeBus()
self.events = []

def set_bus(self, bus):
Expand Down Expand Up @@ -241,7 +241,7 @@ def set_id(self, sched_id: str):
self.skill_id = sched_id

def _get_source_message(self):
message = ovos_utils.messagebus.dig_for_message() or ovos_utils.messagebus.Message("")
message = dig_for_message() or Message("")
message.context['skill_id'] = self.skill_id
return message

Expand Down Expand Up @@ -301,7 +301,7 @@ def on_error(e):
message = self._get_source_message()
context = context or message.context
context["skill_id"] = self.skill_id
self.bus.emit(ovos_utils.messagebus.Message('mycroft.scheduler.schedule_event',
self.bus.emit(Message('mycroft.scheduler.schedule_event',
data=event_data, context=context))

def schedule_event(self, handler: Callable[..., None],
Expand Down
Loading

0 comments on commit d1cdc81

Please sign in to comment.