Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

waiting_for_mycroft #15

Merged
merged 2 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include ovos_utils/res *
32 changes: 32 additions & 0 deletions examples/intent_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ovos_utils.intents import IntentQueryApi
from pprint import pprint


intents = IntentQueryApi()

pprint(intents.get_skill("who are you"))
pprint(intents.get_skill("set volume to 100%"))

exit()
# loaded skills
pprint(intents.get_skills_manifest())
pprint(intents.get_active_skills())

# intent parsing
pprint(intents.get_adapt_intent("who are you"))
pprint(intents.get_padatious_intent("who are you"))
pprint(intents.get_intent("who are you")) # intent that will trigger

# skill from utterance
pprint(intents.get_skill("who are you"))

# registered intents
pprint(intents.get_adapt_manifest())
pprint(intents.get_padatious_manifest())
pprint(intents.get_intent_manifest()) # all of the above

# registered vocab
pprint(intents.get_entities_manifest()) # padatious entities / .entity files
pprint(intents.get_vocab_manifest()) # adapt vocab / .voc files
pprint(intents.get_regex_manifest()) # adapt regex / .rx files
pprint(intents.get_keywords_manifest()) # all of the above
23 changes: 22 additions & 1 deletion ovos_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from time import sleep
import requests
import os
from os.path import isdir, join
from os.path import isdir, join, dirname
import re
import socket
from inflection import camelize, titleize, transliterate, parameterize, ordinalize
Expand All @@ -43,6 +43,22 @@ def get_external_ip():
return requests.get('https://api.ipify.org').text


def resolve_ovos_resource_file(res_name):
"""Convert a resource into an absolute filename.
used internally for ovos resources
"""
# First look for fully qualified file (e.g. a user setting)
if os.path.isfile(res_name):
return res_name

# now look in bundled ovos resources
filename = join(dirname(__file__), "res", res_name)
if os.path.isfile(filename):
return filename

return None # Resource cannot be resolved


def get_mycroft_root():
paths = [
"/opt/venvs/mycroft-core/lib/python3.7/site-packages/", # mark1/2
Expand Down Expand Up @@ -98,6 +114,11 @@ def resolve_resource_file(res_name, root_path=None):
if os.path.isfile(filename):
return filename

# look in ovos_utils package itself
found = resolve_ovos_resource_file(res_name)
if found:
return found

# Finally look for it in the source package
paths = [
"/opt/venvs/mycroft-core/lib/python3.7/site-packages/", # mark1/2
Expand Down
Loading