18423 review changes

This commit is contained in:
Arthur 2025-03-12 08:59:56 -07:00
parent 6d1c84638c
commit 650272d06f
2 changed files with 11 additions and 1 deletions

View File

@ -140,7 +140,7 @@ The Script class provides two convenience methods for reading data from files:
These two methods will load data in YAML or JSON format, respectively, from files within the local path (i.e. `SCRIPTS_ROOT`).
**Note:** These convenience methods only work if running scripts within the local path, they will not work if using a storage other than ScriptFileSystemStorage.
**Note:** These convenience methods are deprecated and will be removed in NetBox v4.4. These only work if running scripts within the local path, they will not work if using a storage other than ScriptFileSystemStorage.
## Logging

View File

@ -563,7 +563,12 @@ class BaseScript:
def load_yaml(self, filename):
"""
Return data from a YAML file
TODO: DEPRECATED: Remove this method in v4.4
"""
self._log(
_("load_yaml is deprecated and will be removed in v4.4"),
level=LogLevelChoices.LOG_WARNING
)
try:
from yaml import CLoader as Loader
except ImportError:
@ -578,7 +583,12 @@ class BaseScript:
def load_json(self, filename):
"""
Return data from a JSON file
TODO: DEPRECATED: Remove this method in v4.4
"""
self._log(
_("load_json is deprecated and will be removed in v4.4"),
level=LogLevelChoices.LOG_WARNING
)
file_path = os.path.join(settings.SCRIPTS_ROOT, filename)
with open(file_path, 'r') as datafile:
data = json.load(datafile)