docutil/docsvg.py
changeset 2705 889ec6db6f7d
parent 2628 40c4449001df
child 3111 5d9ae04ee50f
equal deleted inserted replaced
2704:4ba3bdc7d71f 2705:889ec6db6f7d
    32 def get_inkscape_path():
    32 def get_inkscape_path():
    33     """ Return the Inkscape path """
    33     """ Return the Inkscape path """
    34     if wx.Platform == '__WXMSW__':
    34     if wx.Platform == '__WXMSW__':
    35         from six.moves import winreg
    35         from six.moves import winreg
    36         try:
    36         try:
    37             svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
    37                 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
    38                                            'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
    38                                                'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
    39         except OSError:
    39         except OSError:
    40             svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
    40             try:
    41                                            'Software\\Classes\\inkscape.svg\\shell\\open\\command')
    41                 svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
       
    42                                                'Software\\Classes\\inkscape.svg\\shell\\open\\command')
       
    43             except Exception:
       
    44                 return None
       
    45 
    42         svgexepath = svgexepath.replace('"%1"', '').strip()
    46         svgexepath = svgexepath.replace('"%1"', '').strip()
    43         return svgexepath.replace('"', '')
    47         return svgexepath.replace('"', '')
    44     else:
    48     else:
    45         # TODO: search path
    49         # TODO: search for inkscape in $PATH
    46         return os.path.join("/usr/bin", "inkscape")
    50         svgexepath = os.path.join("/usr/bin", "inkscape")
       
    51         if os.path.exists(svgexepath):
       
    52             return svgexepath
       
    53         return None
    47 
    54 
    48 
    55 
    49 def open_win_svg(svgexepath, svgfile):
    56 def open_win_svg(svgexepath, svgfile):
    50     """ Open Inkscape on Windows platform """
    57     """ Open Inkscape on Windows platform """
    51     popenargs = [svgexepath]
    58     popenargs = [svgexepath]