mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
18423 fix load_yaml / load_json
This commit is contained in:
parent
3ade819706
commit
099242e821
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user