Skip to content

Commit

Permalink
Update presvgwrite.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Nov 19, 2024
1 parent fea64b4 commit 00a97f3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions upcean/predraw/presvgwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
from upcean.xml.downloader import upload_file_to_internet_file
import upcean.support
try:
import svgwrite
except ImportError:
Expand All @@ -43,15 +44,19 @@
from StringIO import StringIO
from StringIO import StringIO as BytesIO

try:
import cairosvg
cairosvgsupport = True
# Define valid CairoSVG output formats
cairo_valid_extensions = {"SVG", "PDF", "PS", "EPS", "PNG"}
except ImportError:
if(upcean.support.cairosvgsupport):
try:
import cairosvg
cairosvgsupport = True
# Define valid CairoSVG output formats
svgwrite_valid_extensions = {"SVG", "PDF", "PS", "EPS", "PNG"}
except ImportError:
cairosvgsupport = False
# Define valid SVGWrite output formats
svgwrite_valid_extensions = {"SVG"}
else:
cairosvgsupport = False
# Define valid SVGWrite output formats
cairo_valid_extensions = {"SVG"}
svgwrite_valid_extensions = {"SVG"}

def get_save_filename(outfile):
"""
Expand Down Expand Up @@ -102,7 +107,7 @@ def get_save_filename(outfile):
outfileext = "SVG"

# Check if extension is supported by Qahirah
if outfileext not in cairo_valid_extensions:
if outfileext not in svgwrite_valid_extensions:
outfileext = "SVG"

return (outfile, outfileext)
Expand All @@ -129,7 +134,7 @@ def get_save_filename(outfile):

ext = ext.strip().upper()
# Check if extension is supported by Qahirah
if ext not in cairo_valid_extensions:
if ext not in svgwrite_valid_extensions:
ext = "SVG"

return (filename, ext)
Expand Down

0 comments on commit 00a97f3

Please sign in to comment.