Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'PosixPath' object has no attribute 'rstrip' #197

Open
ahsansmir opened this issue Oct 7, 2021 · 2 comments
Open

AttributeError: 'PosixPath' object has no attribute 'rstrip' #197

ahsansmir opened this issue Oct 7, 2021 · 2 comments

Comments

@ahsansmir
Copy link

Getting this error while running parliament.

Traceback (most recent call last):
File "/repo/src/initialize_dbx_async_wp.py", line 24, in
from src import iam_policy_extractor
File "/repo/src/iam_policy_extractor.py", line 16, in
from parliament import analyze_policy_string
File "/repo/venv/lib/python3.9/site-packages/parliament/init.py", line 12, in
import pkg_resources
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 3243, in
def _initialize_master_working_set():
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 3226, in _call_aside
f(*args, **kwargs)
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 3268, in _initialize_master_working_set
tuple(
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 3269, in
dist.activate(replace=False)
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 2783, in activate
declare_namespace(pkg)
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 2282, in declare_namespace
_handle_ns(packageName, path_item)
File "/repo/venv/lib/python3.9/site-packages/pkg_resources/init.py", line 2199, in _handle_ns
loader = importer.find_module(packageName)
File "", line 493, in _find_module_shim
File "", line 1428, in find_loader
File "", line 1473, in find_spec
File "", line 64, in _path_join
File "", line 64, in
AttributeError: 'PosixPath' object has no attribute 'rstrip'

@ahsansmir
Copy link
Author

ahsansmir commented Oct 7, 2021

changing module from pkg_resources to importlib in init.py solves this issue.

from importlib import resources

'# On initialization, load the IAM data"

'# check = pkg_resources.resource_filename(name, "iam_definition.json")
'# iam_definition = json.load(open(iam_definition_path, "r"))
iam_definition_path = resources.open_text(name, "iam_definition.json")
iam_definition = json.load(iam_definition_path)

'# And the config data
'# config_path = pkg_resources.resource_filename(name, "config.yaml")
'# config = yaml.safe_load(open(config_path, "r"))
config_path = resources.open_text(name, "config.yaml")
config = yaml.safe_load(config_path)

@ahsansmir ahsansmir reopened this Oct 7, 2021
@ahsansmir
Copy link
Author

making a PR

ahsansmir added a commit to ahsansmir/parliament that referenced this issue Oct 7, 2021
Related to issue duo-labs#197

Changed pkg_resources to importlib
ahsansmir added a commit to ahsansmir/parliament that referenced this issue Oct 7, 2021
Related to issue duo-labs#197 

Changed pkg_resources to importlib for import config files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant