18423 fix load_yaml / load_json

This commit is contained in:
Arthur 2025-02-26 11:32:44 -08:00
parent 3ade819706
commit 099242e821

View File

@ -560,12 +560,6 @@ class BaseScript:
# Convenience functions
#
def get_storage(self):
if self.storage is None:
self.storage = storages.create_storage(storages.backends["scripts"])
return self.storage
def load_yaml(self, filename):
"""
Return data from a YAML file
@ -575,9 +569,8 @@ class BaseScript:
except ImportError:
from yaml import Loader
storage = self.get_storage()
file_path = os.path.join(settings.SCRIPTS_ROOT, filename)
with storage.open(file_path, 'r') as datafile:
with open(file_path, 'r') as datafile:
data = yaml.load(datafile, Loader=Loader)
return data
@ -586,10 +579,8 @@ class BaseScript:
"""
Return data from a JSON file
"""
storage = self.get_storage()
file_path = os.path.join(settings.SCRIPTS_ROOT, filename)
with storage.open(file_path, 'r') as datafile:
with open(file_path, 'r') as datafile:
data = json.load(datafile)
return data