Allow using docutil.get_inkscape_path() on Linux also. svghmi
authorEdouard Tisserant
Mon, 12 Aug 2019 13:06:11 +0200
branchsvghmi
changeset 2755 4efc509e9a1a
parent 2754 a46311f88604
child 2756 f94bc35a023e
Allow using docutil.get_inkscape_path() on Linux also.
docutil/docsvg.py
--- a/docutil/docsvg.py	Fri Aug 09 12:12:24 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: