From 6917a3d925f50d6ddef1e9f821aa76f7f09163a1 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Tue, 12 Sep 2023 20:24:05 +0100 Subject: [PATCH] OVOSkill no longer a direct subclass of MycroftSkill --- ovos_workshop/skills/ovos.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index 8fa7c5cb..dec44c52 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -1,6 +1,6 @@ import re +from abc import ABCMeta from threading import Event - from typing import List, Optional, Union from ovos_bus_client import MessageBusClient @@ -11,13 +11,29 @@ from ovos_utils.skills.audioservice import OCPInterface from ovos_utils.skills.settings import PrivateSettings from ovos_utils.sound import play_audio +from ovos_workshop.decorators.layers import IntentLayers from ovos_workshop.resource_files import SkillResources +from ovos_workshop.skills.base import BaseSkill +from ovos_workshop.skills.mycroft_skill import is_classic_core, MycroftSkill -from ovos_workshop.decorators.layers import IntentLayers -from ovos_workshop.skills.mycroft_skill import MycroftSkill, is_classic_core + +class _OVOSSkillMetaclass(ABCMeta): + """ + To override isinstance checks + """ + + def __instancecheck__(self, instance): + if is_classic_core(): + # instance imported from vanilla mycroft + from mycroft.skills import MycroftSkill as _CoreSkill + if issubclass(self.__class__, _CoreSkill): + return True + + return super().__instancecheck__(instance) or \ + issubclass(self.__class__, MycroftSkill) -class OVOSSkill(MycroftSkill): +class OVOSSkill(BaseSkill, metaclass=_OVOSSkillMetaclass): """ New features: - all patches for MycroftSkill class @@ -140,7 +156,7 @@ def play_audio(self, filename: str): core_supported = True # min version of ovos-core except ImportError: # skills don't require core anymore, running standalone - core_supported = True + core_supported = True if core_supported: message = dig_for_message() or Message("") @@ -223,7 +239,7 @@ def _register_decorated(self): def register_intent_layer(self, layer_name: str, intent_list: List[Union[IntentBuilder, Intent, - str]]): + str]]): """ Register a named intent layer. @param layer_name: Name of intent layer to add