Skip to content

Commit

Permalink
rewritten as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
jnweiger committed Apr 8, 2024
1 parent 64f5e4f commit 5bfbeef
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tools/inkscape_extension/visicut_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,14 @@ def is_exe(fpath):

def inkscape_version():
"""Return Inkscape version number as float, e.g. version "0.92.4" --> return: float 0.92"""
version = subprocess.check_output([INKSCAPEBIN, "--version"], stderr=DEVNULL).decode('ASCII', 'ignore')
if not version.startswith("Inkscape "):
## When inkscape lives in an appimage, AppRun may pollute stdout with extra information.
# Go through all the lines, and find the one that starts with Inkscape
lines = version.splitlines()
for version in lines:
if version.startswith("Inkscape "):
break
assert version.startswith("Inkscape ")
match = re.match("Inkscape ([0-9]+\.[0-9]+).*", version)
assert match is not None
version_raw = subprocess.check_output([INKSCAPEBIN, "--version"], stderr=DEVNULL).decode('ASCII', 'ignore')
## When inkscape lives in an appimage, AppRun may pollute stdout with extra information.
# Go through all the lines, and find the one that starts with Inkscape
lines = version_raw.splitlines()
version = [line for line in lines if line.startswith("Inkscape ")]
assert len(version) == 1, "inkscape --version did not return a version number: " + version_raw
match = re.match("Inkscape ([0-9]+\.[0-9]+).*", version[0])
assert match is not None, "failed to parse version number from " + version[0]
version_float = float(match.group(1))
return version_float

Expand Down

0 comments on commit 5bfbeef

Please sign in to comment.