docutil/docsvg.py
changeset 3482 31f6d7221f60
parent 3477 9ec5ecf9f589
child 3573 1ee56fb544fc
equal deleted inserted replaced
3481:563996733dba 3482:31f6d7221f60
    25 
    25 
    26 from __future__ import absolute_import
    26 from __future__ import absolute_import
    27 import wx
    27 import wx
    28 import subprocess
    28 import subprocess
    29 
    29 
    30 def get_inkscape_path():
    30 
       
    31 def _get_inkscape_path():
    31     """ Return the Inkscape binary path """
    32     """ Return the Inkscape binary path """
    32 
    33 
    33     if wx.Platform == '__WXMSW__':
    34     if wx.Platform == '__WXMSW__':
    34         from six.moves import winreg
    35         from six.moves import winreg
    35         inkcmd = None
    36         inkcmd = None
    53         try:
    54         try:
    54             return subprocess.check_output("command -v inkscape", shell=True).strip()
    55             return subprocess.check_output("command -v inkscape", shell=True).strip()
    55         except subprocess.CalledProcessError:
    56         except subprocess.CalledProcessError:
    56             return None
    57             return None
    57 
    58 
       
    59 _inkscape_path = None
       
    60 def get_inkscape_path():
       
    61     """ Return the Inkscape binary path """
       
    62 
       
    63     global _inkscape_path
       
    64 
       
    65     if _inkscape_path is not None:
       
    66         return _inkscape_path
       
    67 
       
    68     _inkscape_path = _get_inkscape_path()
       
    69     return _inkscape_path
       
    70 
       
    71 
       
    72 def _get_inkscape_version():
       
    73     inkpath = get_inkscape_path()
       
    74     if inkpath is None:
       
    75         return None
       
    76     return map(int, 
       
    77         subprocess.check_output([inkpath,"--version"]).split()[1].split('.'))
       
    78 
       
    79 _inkscape_version = None
       
    80 def get_inkscape_version():
       
    81     global _inkscape_version
       
    82 
       
    83     if _inkscape_version is not None:
       
    84         return _inkscape_version
       
    85 
       
    86     _inkscape_version = _get_inkscape_version()
       
    87     return _inkscape_version
       
    88 
    58 def open_svg(svgfile):
    89 def open_svg(svgfile):
    59     """ Generic function to open SVG file """
    90     """ Generic function to open SVG file """
    60     
    91     
    61     inkpath = get_inkscape_path()
    92     inkpath = get_inkscape_path()
    62     if inkpath is None:
    93     if inkpath is None: