Skip to content

Commit

Permalink
log spam
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 14, 2024
1 parent 9c5bfb5 commit 7ae3425
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
26 changes: 5 additions & 21 deletions ovos_workshop/resource_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}")

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {})
Expand Down

0 comments on commit 7ae3425

Please sign in to comment.