Skip to content

Commit

Permalink
Update warning log to use log_deprecation helper (#188)
Browse files Browse the repository at this point in the history
* Update warning log to use `log_deprecation` helper

* Update internal references to deprecated method

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Mar 5, 2024
1 parent 1f927b0 commit 2f742ff
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ovos_workshop/resource_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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}")
Expand All @@ -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
Expand All @@ -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}")
Expand Down

0 comments on commit 2f742ff

Please sign in to comment.