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

feat:skilljson and homescreen #283

Merged
merged 8 commits into from
Nov 15, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
dont check deprecated dirs (from (from mycroft-core)
  • Loading branch information
JarbasAl committed Nov 14, 2024
commit 8d9a3b1fde38f68c0372eb22e32df601ed20cc93
34 changes: 14 additions & 20 deletions ovos_workshop/resource_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,13 @@ def locate_base_directory(self, skill_directory: str) -> Optional[str]:
return

# check for lang resources shipped by the skill
possible_directories = [Path(skill_directory, "locale", self.language)]
if resource_subdirectory:
possible_directories = (
Path(skill_directory, "locale", self.language),
possible_directories += [
Path(skill_directory, resource_subdirectory, self.language),
Path(skill_directory, resource_subdirectory),
Path(skill_directory, "text", self.language),
)
else:
possible_directories = (
Path(skill_directory, "locale", self.language),
Path(skill_directory, "text", self.language),
)
Path(skill_directory, resource_subdirectory)
]

for directory in possible_directories:
if directory.exists():
self.base_directory = directory
Expand Down Expand Up @@ -331,7 +326,6 @@ def _locate(self) -> Optional[str]:
by the skill author. Walk the directory and any subdirectories to
find the resource file.
"""
from ovos_utils.file_utils import resolve_resource_file
file_path = None
if self.resource_name.endswith(self.resource_type.file_extension):
file_name = self.resource_name
Expand Down Expand Up @@ -376,7 +370,6 @@ def _read(self) -> str:
class QmlFile(ResourceFile):
def _locate(self):
""" QML files are special because we do not want to walk the directory """
from ovos_utils.file_utils import resolve_resource_file
file_path = None
if self.resource_name.endswith(self.resource_type.file_extension):
file_name = self.resource_name
Expand Down Expand Up @@ -477,6 +470,7 @@ def load(self) -> List[List[str]]:

class IntentFile(ResourceFile):
"""Defines an intent file, which skill use to form intents."""

def __init__(self, resource_type, resource_name):
super().__init__(resource_type, resource_name)
self.data = None
Expand Down Expand Up @@ -679,10 +673,10 @@ def load_dialog_file(self, name: str,
dialog_file = DialogFile(self.types.dialog, name)
dialog_file.data = data
return dialog_file.load()

def load_intent_file(self, name: str,
data: Optional[dict] = None,
entities: bool = True) -> List[str]:
data: Optional[dict] = None,
entities: bool = True) -> List[str]:
"""
Loads the contents of an intent file.

Expand Down Expand Up @@ -866,7 +860,7 @@ def load_skill_regex(self, alphanumeric_skill_id: str) -> List[str]:
)

return skill_regexes

@classmethod
def get_available_languages(cls, skill_directory: str) -> List[str]:
"""
Expand All @@ -893,22 +887,22 @@ def get_inventory(self, specific_type: str = "", language: str = "en-us"):
if language not in languages:
raise ValueError(f"Language {language} not available for skill")

inventory = dict()
inventory = dict()
for type_ in self.types:
if specific_type and type_.resource_type != specific_type:
continue

inventory[type_.resource_type] = list()

# search all files in the directory and subdirectories and dump its name in a list
base_dirs = locate_lang_directories(language, self.skill_directory)
for directory in base_dirs:
for file in directory.iterdir():
if file.suffix == type_.file_extension:
inventory[type_.resource_type].append(file.stem)

inventory["languages"] = languages

return inventory

@staticmethod
Expand Down