Skip to content

Commit

Permalink
Use yaml.safe_load instead of hacky string replacement with json.loads
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Oct 3, 2023
1 parent 70bc708 commit 1c02d77
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json

import ckan.plugins as p
import yaml

Check warning on line 2 in ckan/ckanext/ckanext-ytp_main/ckanext/ytp/resourcestatusplugin.py

View check run for this annotation

Codecov / codecov/patch

ckan/ckanext/ckanext-ytp_main/ckanext/ytp/resourcestatusplugin.py#L2

Added line #L2 was not covered by tests
from ckan.plugins.toolkit import config
from ckan.lib.plugins import DefaultTranslation
import ckan.logic as logic
Expand Down Expand Up @@ -82,9 +81,7 @@ def __init__(self, resource):

driver_options = config.get('ckanext.cloudstorage.driver_options')
if driver_options:
# driver options might not be valid json, even though its a dict
driver_options = driver_options.replace("'", '"')
driver_options = json.loads(driver_options)
driver_options = yaml.safe_load(driver_options)
s3 = boto3.client('s3',

Check warning on line 85 in ckan/ckanext/ckanext-ytp_main/ckanext/ytp/resourcestatusplugin.py

View check run for this annotation

Codecov / codecov/patch

ckan/ckanext/ckanext-ytp_main/ckanext/ytp/resourcestatusplugin.py#L82-L85

Added lines #L82 - L85 were not covered by tests
aws_access_key_id=driver_options.get('key'),
aws_secret_access_key=driver_options.get('secret'),
Expand Down

0 comments on commit 1c02d77

Please sign in to comment.