Refs #8: added some error checking for templates without .inf files

This commit is contained in:
Rob McMullen 2018-03-09 11:00:09 -08:00
parent 6ea00e263e
commit 4185ca5617

View File

@ -305,10 +305,15 @@ def get_template_info():
try: try:
with open(name + ".inf", "r") as fh: with open(name + ".inf", "r") as fh:
s = fh.read() s = fh.read()
try:
j = json.loads(s) j = json.loads(s)
except ValueError:
continue
description = j["description"] description = j["description"]
except IOError: except IOError:
description = "" description = ""
if not description:
continue
d = textwrap.wrap(description, 80 - 1 - 14 - 2 - 2) d = textwrap.wrap(description, 80 - 1 - 14 - 2 - 2)
lines.append(fmt % (os.path.basename(name), d[0])) lines.append(fmt % (os.path.basename(name), d[0]))
lines.extend([fmt % ("", line) for line in d[1:]]) lines.extend([fmt % ("", line) for line in d[1:]])