11000 add commenting

This commit is contained in:
Arthur 2022-12-01 13:11:02 -08:00
parent d6e3ad098d
commit c07b0f7b9b

View File

@ -220,6 +220,22 @@ class ImportForm(BootstrapMixin, forms.Form):
records = []
try:
for data in yaml.load_all(data, Loader=yaml.SafeLoader):
"""
checks here are to support both arrays and multiple documents in
yaml data and return as a consistent list for processing (array):
- address: 10.0.1.0/24
status: active
- address: 10.0.1.1/24
status: active
vs (multi-document):
- address: 10.0.1.0/24
status: active
---
- address: 10.0.1.1/24
status: active
device_type output uses multi-document format, but array format
is more common output from other tools.
"""
if type(data) == list:
records.extend(data)
elif type(data) == dict: