Minor changes
This commit is contained in:
parent
00df29aa57
commit
259044ac84
@ -49,8 +49,8 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
sections = ['connectors', 'cables', 'connections']
|
sections = ['connectors', 'cables', 'connections']
|
||||||
types = [dict, dict, list]
|
types = [dict, dict, list]
|
||||||
for sec, ty in zip(sections, types):
|
for sec, ty in zip(sections, types):
|
||||||
if sec in yaml_data and type(yaml_data[sec]) == ty:
|
if sec in yaml_data and type(yaml_data[sec]) == ty: # section exists
|
||||||
if len(yaml_data[sec]) > 0:
|
if len(yaml_data[sec]) > 0: # section has contents
|
||||||
if ty == dict:
|
if ty == dict:
|
||||||
for key, attribs in yaml_data[sec].items():
|
for key, attribs in yaml_data[sec].items():
|
||||||
# The Image dataclass might need to open an image file with a relative path.
|
# The Image dataclass might need to open an image file with a relative path.
|
||||||
@ -63,8 +63,8 @@ def parse(yaml_input: str, file_out: (str, Path) = None, return_types: (None, st
|
|||||||
template_connectors[key] = attribs
|
template_connectors[key] = attribs
|
||||||
elif sec == 'cables':
|
elif sec == 'cables':
|
||||||
template_cables[key] = attribs
|
template_cables[key] = attribs
|
||||||
else:
|
else: # section exists but is empty
|
||||||
pass # section exists but is empty
|
pass
|
||||||
else: # section does not exist, create empty section
|
else: # section does not exist, create empty section
|
||||||
if ty == dict:
|
if ty == dict:
|
||||||
yaml_data[sec] = {}
|
yaml_data[sec] = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user