SVGHMI: Fix launch of POEdit on widows. Parsing oommand in registry based on heuristic was bad, now using regex should be safer. TODO : replicate for Inkscape launch. svghmi
authorEdouard Tisserant
Fri, 19 Feb 2021 12:02:49 +0100
branchsvghmi
changeset 3157 279e08f238ca
parent 3154 a8c81a080588
child 3158 4171f7dd109a
SVGHMI: Fix launch of POEdit on widows. Parsing oommand in registry based on heuristic was bad, now using regex should be safer. TODO : replicate for Inkscape launch.
svghmi/i18n.py
--- a/svghmi/i18n.py	Fri Feb 19 10:04:36 2021 +0100
+++ b/svghmi/i18n.py	Fri Feb 19 12:02:49 2021 +0100
@@ -14,12 +14,15 @@
 import time
 import ast
 import wx
+import re
 
 # to have it for python 2, had to install 
 # https://pypi.org/project/pycountry/18.12.8/
 # python2 -m pip install pycountry==18.12.8 --user
 import pycountry
 
+cmd_parser = re.compile(r'(?:"([^"]+)"\s*|([^\s]+)\s*)?')
+
 def open_pofile(pofile):
     """ Opens PO file with POEdit """
     
@@ -29,7 +32,9 @@
         try:
             poedit_cmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
                                            'SOFTWARE\\Classes\\poedit\\shell\\open\\command')
-            poedit_path = poedit_cmd.replace('"%1"', '').strip().replace('"', '')
+            cmd = re.findall(cmd_parser, poedit_cmd)
+            dblquote_value,smpl_value = cmd[0]
+            poedit_path = dblquote_value+smpl_value
         except OSError:
             poedit_path = None