fix: pkg_resources with importlib.resources (#766)

This commit is contained in:
Robert Kaussow 2024-01-31 10:28:46 +01:00 committed by GitHub
parent ce0d895fc4
commit 48baa2f338
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
"""Global settings object definition."""
import importlib.resources
import os
import anyconfig
@ -7,7 +8,6 @@ import jsonschema.exceptions
import pathspec
from appdirs import AppDirs
from jsonschema._utils import format_as_index
from pkg_resources import resource_filename
from ansiblelater import utils
@ -105,9 +105,9 @@ class Settings:
defaults["ansible"]["custom_modules"].append(f)
if defaults["rules"]["builtin"]:
defaults["rules"]["dir"].append(
os.path.join(resource_filename("ansiblelater", "rules"))
)
ref = importlib.resources.files("ansiblelater") / "rules"
with importlib.resources.as_file(ref) as path:
defaults["rules"]["dir"].append(path)
defaults["rules"]["dir"] = [
os.path.relpath(os.path.normpath(p)) for p in defaults["rules"]["dir"]