fail if picture doesn't exist

This commit is contained in:
Matt Venn
2023-04-19 17:10:12 +02:00
parent 6249de0b0d
commit c99cfc1612
+12 -4
View File
@@ -42,12 +42,20 @@ def create_pdf(yaml):
# handle pictures
yaml['picture_link'] = ''
if yaml['picture']:
# skip SVG for now, not supported by pandoc
picture_name = yaml['picture']
if 'svg' not in picture_name:
yaml['picture_link'] = '![picture]({})'.format(picture_name)
else:
# check it's actually there
if not os.path.exists(picture_name):
logging.warning(f"picture {picture_name} not found")
exit(1)
# and not SVG
if picture_name.endswith('.svg'):
logging.warning("svg not supported")
exit(1)
# create the link
yaml['picture_link'] = '![picture]({})'.format(picture_name)
# now build the doc & print it
try: