Skip to content

Commit

Permalink
fix/core_root_location (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Apr 29, 2023
1 parent 3609c3e commit 64e89b0
Showing 1 changed file with 31 additions and 4 deletions.
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

0 comments on commit 64e89b0

Please sign in to comment.