Allow using docutil.get_inkscape_path() on Linux also.
authorEdouard Tisserant
Mon, 12 Aug 2019 13:06:11 +0200
changeset 2628 40c4449001df
parent 2627 3ba6a2d26507
child 2629 caa43c61f90c
Allow using docutil.get_inkscape_path() on Linux also.
docutil/docsvg.py
--- a/docutil/docsvg.py	Fri Aug 09 12:07:33 2019 +0200
+++ b/docutil/docsvg.py	Mon Aug 12 13:06:11 2019 +0200
@@ -31,15 +31,19 @@
 
 def get_inkscape_path():
     """ Return the Inkscape path """
-    from six.moves import winreg
-    try:
-        svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                       'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
-    except OSError:
-        svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                       'Software\\Classes\\inkscape.svg\\shell\\open\\command')
-    svgexepath = svgexepath.replace('"%1"', '')
-    return svgexepath.replace('"', '')
+    if wx.Platform == '__WXMSW__':
+        from six.moves import winreg
+        try:
+            svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+                                           'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
+        except OSError:
+            svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+                                           'Software\\Classes\\inkscape.svg\\shell\\open\\command')
+        svgexepath = svgexepath.replace('"%1"', '').strip()
+        return svgexepath.replace('"', '')
+    else:
+        # TODO: search path
+        return os.path.join("/usr/bin", "inkscape")
 
 
 def open_win_svg(svgexepath, svgfile):
@@ -65,7 +69,7 @@
             wx.MessageBox("Inkscape is not found or installed !")
             return None
     else:
-        svgexepath = os.path.join("/usr/bin", "inkscape")
+        svgexepath=get_inkscape_path()
         if os.path.isfile(svgexepath):
             open_lin_svg(svgexepath, svgfile)
         else: