Fix imporlib.resources deprecation warning

This commit is contained in:
Stéphane Bidoul 2023-11-19 12:54:06 +01:00
parent bc534e923c
commit 3ab5be6a27
2 changed files with 6 additions and 2 deletions

View file

@ -183,7 +183,9 @@ def _get_kubefiles_path(kubefiles_path: Path | None) -> Generator[Path, None, No
if kubefiles_path: if kubefiles_path:
yield kubefiles_path yield kubefiles_path
else: else:
with resources.path(__package__, "kubefiles") as default_kubefiles_path: with resources.as_file(
resources.files(__package__).joinpath("kubefiles")
) as default_kubefiles_path:
yield default_kubefiles_path yield default_kubefiles_path

View file

@ -40,7 +40,9 @@ def mount(app: FastAPI) -> None:
directory, which is then mounted under the /webui route. directory, which is then mounted under the /webui route.
""" """
webui_path = Path(__file__).parent / "webui" webui_path = Path(__file__).parent / "webui"
with resources.path("runboat", "webui-templates") as webui_template_path: with resources.as_file(
resources.files(__package__).joinpath("webui-templates")
) as webui_template_path:
for path in webui_template_path.iterdir(): for path in webui_template_path.iterdir():
if path.name.endswith(".jinja"): if path.name.endswith(".jinja"):
template = jinja2.Template(path.read_text()) template = jinja2.Template(path.read_text())