--- a/docutil/docsvg.py Mon Aug 21 20:17:19 2017 +0000
+++ b/docutil/docsvg.py Mon Aug 21 23:22:58 2017 +0300
@@ -22,41 +22,46 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-import wx, os, subprocess
+import wx
+import os
+import subprocess
+
def get_inkscape_path():
""" Return the Inkscape path """
import _winreg
svgexepath = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE,
- 'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
+ 'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
svgexepath = svgexepath.replace('"%1"', '')
return svgexepath.replace('"', '')
+
def open_win_svg(svgexepath, svgfile):
""" Open Inkscape on Windows platform """
popenargs = [svgexepath]
- if svgfile is not None :
+ if svgfile is not None:
popenargs.append(svgfile)
subprocess.Popen(popenargs).pid
+
def open_lin_svg(svgexepath, svgfile):
""" Open Inkscape on Linux platform """
if os.path.isfile("/usr/bin/inkscape"):
- os.system("%s %s &"%(svgexepath , svgfile))
-
+ os.system("%s %s &" % (svgexepath, svgfile))
+
+
def open_svg(svgfile):
""" Generic function to open SVG file """
- if wx.Platform == '__WXMSW__' :
+ if wx.Platform == '__WXMSW__':
try:
open_win_svg(get_inkscape_path(), svgfile)
- except:
+ except Exception:
wx.MessageBox("Inkscape is not found or installed !")
return None
else:
- svgexepath = os.path.join("/usr/bin","inkscape")
+ svgexepath = os.path.join("/usr/bin", "inkscape")
if(os.path.isfile(svgexepath)):
open_lin_svg(svgexepath, svgfile)
else:
wx.MessageBox("Inkscape is not found or installed !")
return None
-