diff --git a/ovos_workshop/resource_files.py b/ovos_workshop/resource_files.py index 0416355..be44f38 100644 --- a/ovos_workshop/resource_files.py +++ b/ovos_workshop/resource_files.py @@ -13,13 +13,14 @@ # limitations under the License. # """Handling of skill data such as intents and regular expressions.""" +import abc import json import re from collections import namedtuple from os import walk from os.path import dirname from pathlib import Path -from typing import List, Optional, Tuple, Dict +from typing import List, Optional, Tuple, Dict, Any from langcodes import tag_distance from ovos_config.config import Configuration @@ -323,7 +324,7 @@ def __init__(self, resource_type: ResourceType, resource_name: str): self.resource_name = resource_name self.file_path = self._locate() - def _locate(self) -> str: + def _locate(self) -> Optional[str]: """Locates a resource file in the skill's locale directory. A skill's locale directory can contain a subdirectory structure defined @@ -353,22 +354,12 @@ def _locate(self) -> str: if file_name in file_names: file_path = Path(directory, file_name) - # check the core resources - if file_path is None and self.resource_type.language: - sub_path = Path("text", self.resource_type.language, file_name) - file_path = resolve_resource_file(str(sub_path), - config=Configuration()) - - # check non-lang specific core resources - if file_path is None: - file_path = resolve_resource_file(file_name, - config=Configuration()) - if file_path is None: LOG.debug(f"Could not find resource file {file_name} for lang: {self.resource_type.language}") return file_path + @abc.abstractmethod def load(self): """Override in subclass to define resource type loading behavior.""" pass @@ -406,13 +397,6 @@ def _locate(self): if x.is_file() and file_name == x.name: file_path = Path(self.resource_type.base_directory, file_name) - # check the core resources - if file_path is None: - file_path = resolve_resource_file(file_name, - config=Configuration()) or \ - resolve_resource_file(f"ui/{file_name}", - config=Configuration()) - if file_path is None: LOG.error(f"Could not find resource file {file_name}") @@ -423,7 +407,7 @@ def load(self): class JsonFile(ResourceFile): - def load(self) -> Dict[str, str]: + def load(self) -> Dict[str, Any]: if self.file_path is not None: with open(self.file_path) as f: return json.load(f) diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index 21fa7ad..24aec96 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -1723,7 +1723,7 @@ def speak_dialog(self, key: str, data: Optional[dict] = None, expect_response, wait, meta={'dialog': key, 'data': data} ) else: - self.log.warning( + self.log.error( 'dialog_render is None, does the locale/dialog folder exist?' ) self.speak(key, expect_response, wait, {})