pull/76/head
meisnate12 4 years ago
parent 861df0a97e
commit 92d5e29a91

@ -54,10 +54,7 @@ class CollectionBuilder:
if template["default"]: if template["default"]:
if isinstance(template["default"], dict): if isinstance(template["default"], dict):
for dv in template["default"]: for dv in template["default"]:
if template["default"][dv]:
default[dv] = template["default"][dv] default[dv] = template["default"][dv]
else:
raise Failed(f"Collection Error: template default sub-attribute {dv} is blank")
else: else:
raise Failed("Collection Error: template sub-attribute default is not a dictionary") raise Failed("Collection Error: template sub-attribute default is not a dictionary")
else: else:
@ -75,12 +72,15 @@ class CollectionBuilder:
txt = txt.replace("<<collection_name>>", str(self.name)) txt = txt.replace("<<collection_name>>", str(self.name))
for dm in default: for dm in default:
if f"<<{dm}>>" in txt: if f"<<{dm}>>" in txt:
if default[dm] is None:
raise Failed(f"template default {dm} is blank")
txt = txt.replace(f"<<{dm}>>", str(default[dm])) txt = txt.replace(f"<<{dm}>>", str(default[dm]))
if txt in ["true", "True"]: return True if txt in ["true", "True"]: return True
elif txt in ["false", "False"]: return False elif txt in ["false", "False"]: return False
else: else:
try: return int(txt) try: return int(txt)
except ValueError: return txt except ValueError: return txt
try:
if isinstance(template[m], dict): if isinstance(template[m], dict):
attr = {} attr = {}
for sm in template[m]: for sm in template[m]:
@ -103,6 +103,8 @@ class CollectionBuilder:
attr.append(replace_txt(li)) attr.append(replace_txt(li))
else: else:
attr = replace_txt(template[m]) attr = replace_txt(template[m])
except Failed:
continue
self.data[m] = attr self.data[m] = attr
else: else:
raise Failed(f"Collection Error: template attribute {m} is blank") raise Failed(f"Collection Error: template attribute {m} is blank")

Loading…
Cancel
Save