Fix export when cairosvg module is not found

If not found, the program should not try to export the image using it
anyway.
master
Niels Giorno 2020-08-28 12:52:53 +02:00
parent deb2e031a1
commit 01f90de9c2
1 changed files with 13 additions and 12 deletions

View File

@ -114,21 +114,22 @@ def generate_outfile(
)
log.debug(e)
svg_str = jj2_tpl.render(context)
else:
svg_str = jj2_tpl.render(context)
if outfilename.suffix == ".png":
conversion_fun = cairosvg.svg2png
elif outfilename.suffix == ".pdf":
conversion_fun = cairosvg.svg2pdf
elif outfilename.suffix == ".ps":
conversion_fun = cairosvg.svg2ps
if outfilename.suffix == ".png":
conversion_fun = cairosvg.svg2png
elif outfilename.suffix == ".pdf":
conversion_fun = cairosvg.svg2pdf
elif outfilename.suffix == ".ps":
conversion_fun = cairosvg.svg2ps
conversion_fun(
bytestring = svg_str,
write_to = str(outfilename),
)
conversion_fun(
bytestring = svg_str,
write_to = str(outfilename),
)
return outfilename
return outfilename
# To unsupported format
# -------------------------------------------------------------------------