Skip to content

Commit

Permalink
refactor utils into helpers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed May 9, 2022
1 parent f2a8a69 commit a546488
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ovos_workshop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ovos_utils.skills.settings import PrivateSettings
from ovos_utils.sound import wait_while_speaking

from ovos_workshop.skills.base import Intent, IntentBuilder, get_non_properties
from ovos_workshop.helpers import Intent, IntentBuilder, get_non_properties
from ovos_workshop.skills.decorators import *
from ovos_workshop.skills.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
Expand Down
2 changes: 1 addition & 1 deletion ovos_workshop/skills/base.py → ovos_workshop/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, name=''):


def get_non_properties(obj):
"""Get attibutes that are not properties from object.
"""Get attributes that are not properties from object.
Will return members of object class along with bases down to MycroftSkill.
Expand Down
26 changes: 1 addition & 25 deletions ovos_workshop/patches/base_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,7 @@
from mycroft.skills.skill_data import read_vocab_file, load_vocabulary, \
load_regex
from mycroft.dialog import load_dialogs


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.
Arguments:
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 not in (object, MycroftSkill)]:
np += check_class(b)
return np

return set(check_class(obj.__class__))
from ovos_workshop.helpers import get_non_properties


class MycroftSkill(_MycroftSkill):
Expand Down
2 changes: 1 addition & 1 deletion ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from mycroft import dialog
from mycroft.skills.mycroft_skill.event_container import create_wrapper
from ovos_workshop.skills.base import get_non_properties, Intent, IntentBuilder
from ovos_workshop.helpers 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
Expand Down

0 comments on commit a546488

Please sign in to comment.