From 2f742ff9c4091b062599222e240029ec4bcb140f Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Mon, 4 Mar 2024 21:06:35 -0800 Subject: [PATCH] Update warning log to use `log_deprecation` helper (#188) * Update warning log to use `log_deprecation` helper * Update internal references to deprecated method --------- Co-authored-by: Daniel McKnight --- ovos_workshop/resource_files.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ovos_workshop/resource_files.py b/ovos_workshop/resource_files.py index b337f90a..556ef9dd 100644 --- a/ovos_workshop/resource_files.py +++ b/ovos_workshop/resource_files.py @@ -28,8 +28,7 @@ from ovos_utils.bracket_expansion import expand_options from ovos_utils import flatten_list from ovos_utils.dialog import MustacheDialogRenderer, load_dialogs -from ovos_utils.log import LOG - +from ovos_utils.log import LOG, log_deprecation SkillResourceTypes = namedtuple( "SkillResourceTypes", @@ -121,9 +120,8 @@ def resolve_resource_file(res_name: str) -> Optional[str]: Returns: (str) path to resource or None if no resource found """ - # TODO: Deprecate in 0.1.0 - LOG.warning(f"This method has moved to `ovos_utils.file_utils` and will be" - f"removed in a future release.") + log_deprecation(f"This method has moved to `ovos_utils.file_utils`", + "0.1.0") from ovos_utils.file_utils import resolve_resource_file config = Configuration() return resolve_resource_file(res_name, config=config) @@ -316,6 +314,7 @@ def _locate(self) -> 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 @@ -341,11 +340,13 @@ def _locate(self) -> str: # 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)) + 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) + file_path = resolve_resource_file(file_name, + config=Configuration()) if file_path is None: LOG.error(f"Could not find resource file {file_name}") @@ -368,6 +369,7 @@ 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 @@ -390,8 +392,10 @@ def _locate(self): # check the core resources if file_path is None: - file_path = resolve_resource_file(file_name) or \ - resolve_resource_file(f"ui/{file_name}") + 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}")