Skip to content

Commit

Permalink
Replace pkg_resources.resource_string with `importlib.resources.fil…
Browse files Browse the repository at this point in the history
…es` [all tests ci] (#1468)

* replace pkg_resources with importlib.resources

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused pkg_resources import

* update __name__ to __package__ and use read_text

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused pkg_resources again

* update whats new

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
leewujung and pre-commit-ci[bot] authored Feb 22, 2025
1 parent 789bd4e commit 4e9ac28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This release includes the critical migration to use the new `xr.DataTree` functi
## Bug and warning fixes
* Assemble AD2CP timestamp with nanosecond precision by @leewujung in /~https://github.com/OSOceanAcoustics/echopype/pull/1436
* Use `import_resources.files` instead of the legacy `open_text` by @leewujung in /~https://github.com/OSOceanAcoustics/echopype/pull/1434
* Replace `pkg_resources.resource_string` with `importlib.resources.files` by @leewujung in /~https://github.com/OSOceanAcoustics/echopype/pull/1468
* Fix invalid `\d` warning by using raw string by @leewujung in /~https://github.com/OSOceanAcoustics/echopype/pull/1448
* Check if there exist any swap files before cleaning them up by @ctuguinay in /~https://github.com/OSOceanAcoustics/echopype/pull/1451
* Remove `__setattr__` from EchoData by @leewujung in /~https://github.com/OSOceanAcoustics/echopype/pull/1457
Expand Down
4 changes: 2 additions & 2 deletions echopype/echodata/widgets/widgets.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime
import html
from functools import lru_cache
from importlib.resources import files
from pathlib import Path

import pkg_resources
from jinja2 import Environment, FileSystemLoader, Template
from jinja2.exceptions import TemplateNotFound

Expand Down Expand Up @@ -36,7 +36,7 @@ def _load_static_files():
"""Lazily load the resource files into memory the first time they are needed.
Clone from xarray.core.formatted_html_template.
"""
return [pkg_resources.resource_string(__name__, fname).decode("utf8") for fname in STATIC_FILES]
return [files(__package__).joinpath(fname).read_text(encoding="utf8") for fname in STATIC_FILES]


def get_environment() -> Environment:
Expand Down

0 comments on commit 4e9ac28

Please sign in to comment.