-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters