Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/core_root_location #134

Merged
merged 1 commit into from
Apr 29, 2023
Merged
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
35 changes: 31 additions & 4 deletions ovos_utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,44 @@ def resolve_ovos_resource_file(res_name: str) -> Optional[str]:
if os.path.isfile(res_name):
return res_name

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

# let's look in ovos_workshop if it's installed
# (default skill resources live here)
try:
import ovos_workshop
core_root = dirname(ovos_workshop.__file__)
filename = join(core_root, "res", res_name)
if os.path.isfile(filename):
return filename
except:
pass

# let's look in ovos_gui if it's installed
# (default GUI resources live here)
try:
import ovos_gui
core_root = dirname(ovos_gui.__file__)
filename = join(core_root, "res", res_name)
if os.path.isfile(filename):
return filename
except:
pass

# let's look in mycroft/ovos-core if it's installed
path = search_mycroft_core_location()
if path:
filename = join(path, "mycroft", "res", res_name)
# (default core resources live here / backwards compat)
try:
import mycroft
core_root = dirname(mycroft.__file__)
filename = join(core_root, "res", res_name)
if os.path.isfile(filename):
return filename
except:
pass

return None # Resource cannot be resolved


Expand Down