Skip to content

Commit

Permalink
use importlib for all reading
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpyke committed Dec 16, 2024
1 parent e041c9c commit 3784b5c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 83 deletions.
18 changes: 4 additions & 14 deletions iam_builder/iam_schema.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import jsonschema
import json
from iam_builder.exceptions import IAMValidationError
import importlib_resources

try:
import pkg_resources
except Exception as e:
print("Error importing pkg_resources", e)
import importlib


try:
ref = importlib_resources.files(__name__).joinpath("schemas/iam_schema.json")
with ref.open('rb') as fp:
IAM_SCHEMA = json.load(
pkg_resources.resource_stream(__name__, "schemas/iam_schema.json")
fp
)
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
79 changes: 12 additions & 67 deletions poetry.lock

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

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.9"
PyYAML = "^6.0"
parameterized = "0.7.*"
jsonschema = "^4.10.0"
importlib = "^1.0.4"
importlib-resources = "^6.4.5"

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

0 comments on commit 3784b5c

Please sign in to comment.