Skip to content

Commit

Permalink
adapt deprecation logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 20, 2023
1 parent 5f78bc3 commit 7e5c016
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions ovos_core/intent_services/adapt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ovos_plugin_manager.templates.pipeline import PipelineComponentPlugin, IntentMatch
from ovos_utils import flatten_list, classproperty
from ovos_utils.intents.intent_service_interface import open_intent_envelope
from ovos_utils.log import LOG
from ovos_utils.log import LOG, deprecated, log_deprecation
from ovos_utils.messagebus import get_message_lang, get_mycroft_bus


Expand Down Expand Up @@ -318,60 +318,64 @@ def detach_intent(self, intent_name):
# deprecated properties / backwards compat
@property
def context_keywords(self):
LOG.warning(
"self.context_keywords has been deprecated and is unused, use self.config.get('keywords', []) instead")
log_deprecation("self.context_keywords has been deprecated and is unused,"
" use self.config.get('keywords', []) instead", "0.1.0")
return self.config.get('keywords', [])

@context_keywords.setter
def context_keywords(self, val):
LOG.warning(
"self.context_keywords has been deprecated and is unused, edit mycroft.conf instead, setter will be ignored")
log_deprecation("self.context_keywords has been deprecated and is unused, "
"edit mycroft.conf instead, setter will be ignored", "0.1.0")

@property
def context_max_frames(self):
LOG.warning(
"self.context_keywords has been deprecated and is unused, use self.config.get('max_frames', 3) instead")
log_deprecation("self.context_keywords has been deprecated and is unused, "
"use self.config.get('max_frames', 3) instead", "0.1.0")
return self.config.get('max_frames', 3)

@context_max_frames.setter
def context_max_frames(self, val):
LOG.warning(
"self.context_max_frames has been deprecated and is unused, edit mycroft.conf instead, setter will be ignored")
log_deprecation("self.context_max_frames has been deprecated and is unused, "
"edit mycroft.conf instead, setter will be ignored", "0.1.0")

@property
def context_timeout(self):
LOG.warning("self.context_timeout has been deprecated and is unused, use self.config.get('timeout', 2) instead")
log_deprecation("self.context_timeout has been deprecated and is unused,"
" use self.config.get('timeout', 2) instead", "0.1.0")
return self.config.get('timeout', 2)

@context_timeout.setter
def context_timeout(self, val):
LOG.warning(
"self.context_timeout has been deprecated and is unused, edit mycroft.conf instead, setter will be ignored")

log_deprecation("self.context_timeout has been deprecated and is unused,"
" edit mycroft.conf instead, setter will be ignored", "0.1.0")

@property
def context_greedy(self):
LOG.warning(
"self.context_greedy has been deprecated and is unused, use self.config.get('greedy', False) instead")
log_deprecation("self.context_greedy has been deprecated and is unused, "
"use self.config.get('greedy', False) instead", "0.1.0")
return self.config.get('greedy', False)

@context_greedy.setter
def context_greedy(self, val):
LOG.warning(
"self.context_greedy has been deprecated and is unused, edit mycroft.conf instead, setter will be ignored")
log_deprecation("self.context_greedy has been deprecated and is unused,"
" edit mycroft.conf instead, setter will be ignored", "0.1.0")

@property
def context_manager(self):
LOG.warning("context_manager has been deprecated, use Session.context instead")
log_deprecation("context_manager has been deprecated, use Session.context instead", "0.1.0")
sess = SessionManager.get()
return sess.context

@context_manager.setter
def context_manager(self, val):
LOG.warning("context_manager has been deprecated, use Session.context instead")
log_deprecation("context_manager has been deprecated, use Session.context instead", "0.1.0")

assert isinstance(val, ContextManager)
sess = SessionManager.get()
sess.context = val

@deprecated("update_context has been deprecated, use Session.context.update_context instead", "0.1.0")
def update_context(self, intent):
"""Updates context with keyword from the intent.
Expand All @@ -382,7 +386,6 @@ def update_context(self, intent):
Args:
intent: Intent to scan for keywords
"""
LOG.warning("update_context has been deprecated, use Session.context.update_context instead")
sess = SessionManager.get()
ents = [tag['entities'][0] for tag in intent['__tags__'] if 'entities' in tag]
sess.context.update_context(ents)
Expand Down

0 comments on commit 7e5c016

Please sign in to comment.