mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
18423 review changes
This commit is contained in:
parent
6d1c84638c
commit
650272d06f
@ -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`).
|
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
|
## Logging
|
||||||
|
|
||||||
|
@ -563,7 +563,12 @@ class BaseScript:
|
|||||||
def load_yaml(self, filename):
|
def load_yaml(self, filename):
|
||||||
"""
|
"""
|
||||||
Return data from a YAML file
|
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:
|
try:
|
||||||
from yaml import CLoader as Loader
|
from yaml import CLoader as Loader
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -578,7 +583,12 @@ class BaseScript:
|
|||||||
def load_json(self, filename):
|
def load_json(self, filename):
|
||||||
"""
|
"""
|
||||||
Return data from a JSON file
|
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)
|
file_path = os.path.join(settings.SCRIPTS_ROOT, filename)
|
||||||
with open(file_path, 'r') as datafile:
|
with open(file_path, 'r') as datafile:
|
||||||
data = json.load(datafile)
|
data = json.load(datafile)
|
||||||
|
Loading…
Reference in New Issue
Block a user