From c99cfc161230322c000bf1158b3adea636311942 Mon Sep 17 00:00:00 2001 From: Matt Venn Date: Wed, 19 Apr 2023 17:10:12 +0200 Subject: [PATCH] fail if picture doesn't exist --- documentation.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/documentation.py b/documentation.py index fbf02e0..c53980a 100644 --- a/documentation.py +++ b/documentation.py @@ -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: