--- a/docutil/docsvg.py Fri Jan 15 10:15:41 2021 +0100
+++ b/docutil/docsvg.py Mon Jan 18 10:32:13 2021 +0100
@@ -24,61 +24,38 @@
from __future__ import absolute_import
- """ Return the Inkscape path """
+ """ Return the Inkscape binary path """ if wx.Platform == '__WXMSW__':
from six.moves import winreg
- svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
- 'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
+ inkcmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, + 'Software\\Classes\\svgfile\\shell\\Inkscape\\command') - svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+ inkcmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\inkscape.svg\\shell\\open\\command')
- svgexepath = svgexepath.replace('"%1"', '').strip()
- return svgexepath.replace('"', '')
- # TODO: search for inkscape in $PATH
- svgexepath = os.path.join("/usr/bin", "inkscape")
- if os.path.exists(svgexepath):
+ return inkcmd.replace('"%1"', '').strip().replace('"', '') -def open_win_svg(svgexepath, svgfile):
- """ Open Inkscape on Windows platform """
- popenargs = [svgexepath]
- if svgfile is not None:
- popenargs.append(svgfile)
- subprocess.Popen(popenargs)
-def open_lin_svg(svgexepath, svgfile):
- """ Open Inkscape on Linux platform """
- if os.path.isfile("/usr/bin/inkscape"):
- os.system("%s %s &" % (svgexepath, svgfile))
+ return subprocess.check_output("command -v inkscape", shell=True).strip() + except subprocess.CalledProcessError: """ Generic function to open SVG file """
- if wx.Platform == '__WXMSW__':
- open_win_svg(get_inkscape_path(), svgfile)
- wx.MessageBox("Inkscape is not found or installed !")
+ inkpath = get_inkscape_path() + wx.MessageBox("Inkscape is not found or installed !") - svgexepath=get_inkscape_path()
- if os.path.isfile(svgexepath):
- open_lin_svg(svgexepath, svgfile)
- wx.MessageBox("Inkscape is not found or installed !")
+ subprocess.Popen([inkpath,svgfile])