Skip to content

Commit

Permalink
optional adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed May 7, 2022
1 parent 97f3de0 commit 59086b4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
18 changes: 9 additions & 9 deletions ovos_workshop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
from os import listdir
from os.path import isdir, exists


from mycroft_bus_client.message import dig_for_message
from ovos_utils import get_handler_name
from ovos_utils.configuration import read_mycroft_config
from ovos_utils.dialog import join_list, load_dialogs, get_dialog
from ovos_utils.enclosure.api import EnclosureAPI
from ovos_utils.events import *
from ovos_utils.events import EventContainer
from ovos_utils.events import create_wrapper
from ovos_utils.file_utils import *
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.gui import GUIInterface
from ovos_utils.intents.intent_service_interface import \
IntentServiceInterface, munge_intent_parser
from ovos_utils.intents.intent_service_interface import munge_regex
from ovos_utils.log import LOG
from ovos_utils.messagebus import get_mycroft_bus
from ovos_utils.parse import match_one
from ovos_utils.skills.audioservice import AudioServiceInterface
from ovos_utils.skills.settings import PrivateSettings
from ovos_utils.sound import wait_while_speaking
from ovos_workshop.skills.decorators import *

from ovos_workshop.skills.base import Intent, IntentBuilder, get_non_properties
from ovos_workshop.skills.decorators import *
from ovos_workshop.skills.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
from ovos_utils.skills.audioservice import AudioServiceInterface
from ovos_utils.events import EventContainer
from ovos_workshop.skills.layers import IntentLayers
from ovos_workshop.skills.ovos import Intent, IntentBuilder, get_non_properties
from ovos_utils.gui import GUIInterface
from ovos_utils.intents.intent_service_interface import munge_regex
from ovos_utils.events import create_wrapper

# LF imports are only used in ask_selection, they are optional and provide
# numeric input support, eg. "select the first option"
try:
Expand Down Expand Up @@ -1147,7 +1147,7 @@ def register_resting_screen(self):
if hasattr(method, 'resting_handler'):
self.resting_name = method.resting_handler
LOG.info('Registering resting screen {} for {}.'.format(
method, self.resting_name))
method, self.resting_name))

# Register for handling resting screen
msg_type = '{}.{}'.format(self.skill_id, 'idle')
Expand Down
31 changes: 31 additions & 0 deletions ovos_workshop/skills/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
try:
from adapt.intent import IntentBuilder, Intent
except ImportError:
# adapt is optional, OVOSAbstractApplication might not use intents
IntentBuilder = Intent = None


def get_non_properties(obj):
"""Get attibutes that are not properties from object.
Will return members of object class along with bases down to MycroftSkill.
Args:
obj: object to scan
Returns:
Set of attributes that are not a property.
"""

def check_class(cls):
"""Find all non-properties in a class."""
# Current class
d = cls.__dict__
np = [k for k in d if not isinstance(d[k], property)]
# Recurse through base classes excluding MycroftSkill and object
for b in [b for b in cls.__bases__ if b.__name__ not in ("object", "MycroftSkill")]:
np += check_class(b)
return np

return set(check_class(obj.__class__))

10 changes: 1 addition & 9 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@

from mycroft import dialog
from mycroft.skills.mycroft_skill.event_container import create_wrapper

from mycroft.skills.mycroft_skill.mycroft_skill import get_non_properties
from ovos_workshop.skills.base import get_non_properties, Intent, IntentBuilder
from ovos_workshop.patches.base_skill import MycroftSkill, FallbackSkill
from ovos_workshop.skills.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
from ovos_workshop.skills.layers import IntentLayers


try:
from adapt.intent import IntentBuilder, Intent
except ImportError:
# adapt is optional, OVOSAbstractApplication might not use intents
IntentBuilder = Intent = None


class OVOSSkill(MycroftSkill):
"""
New features:
Expand Down

0 comments on commit 59086b4

Please sign in to comment.