Skip to content

Commit

Permalink
Update to fix pkg_resources deprecation while maintaining back compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpyke committed Dec 16, 2024
1 parent ba74248 commit cfc724c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
21 changes: 17 additions & 4 deletions iam_builder/iam_schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import jsonschema
import json
import pkg_resources
import importlib
from iam_builder.exceptions import IAMValidationError

IAM_SCHEMA = json.load(
pkg_resources.resource_stream(__name__, "schemas/iam_schema.json")
)
try:
import pkg_resources
except ImportError:
import importlib


try:
IAM_SCHEMA = json.load(
pkg_resources.resource_stream(__name__, "schemas/iam_schema.json")
)
except ImportError:
ref = importlib_resources.files(__name__).joinpath("schemas/iam_schema.json")
with ref.open('rb') as fp:
IAM_SCHEMA = json.load(
fp.read()
)


def validate_iam(config: dict):
Expand Down
14 changes: 12 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python = "^3.7"
PyYAML = "^6.0"
parameterized = "0.7.*"
jsonschema = "^4.10.0"
importlib = "^1.0.4"

[tool.poetry.scripts]
iam_builder = "iam_builder.command_line:main"
Expand Down

0 comments on commit cfc724c

Please sign in to comment.