svghmi/i18n.py
branchsvghmi
changeset 3160 cecfd6bb4593
parent 3157 279e08f238ca
child 3198 d9c8f8789fc8
equal deleted inserted replaced
3156:76c0c0a524c9 3160:cecfd6bb4593
    12 import sys
    12 import sys
    13 import subprocess
    13 import subprocess
    14 import time
    14 import time
    15 import ast
    15 import ast
    16 import wx
    16 import wx
       
    17 import re
    17 
    18 
    18 # to have it for python 2, had to install 
    19 # to have it for python 2, had to install 
    19 # https://pypi.org/project/pycountry/18.12.8/
    20 # https://pypi.org/project/pycountry/18.12.8/
    20 # python2 -m pip install pycountry==18.12.8 --user
    21 # python2 -m pip install pycountry==18.12.8 --user
    21 import pycountry
    22 import pycountry
       
    23 
       
    24 cmd_parser = re.compile(r'(?:"([^"]+)"\s*|([^\s]+)\s*)?')
    22 
    25 
    23 def open_pofile(pofile):
    26 def open_pofile(pofile):
    24     """ Opens PO file with POEdit """
    27     """ Opens PO file with POEdit """
    25     
    28     
    26     if sys.platform.startswith('win'):
    29     if sys.platform.startswith('win'):
    27         from six.moves import winreg
    30         from six.moves import winreg
    28         poedit_cmd = None
    31         poedit_cmd = None
    29         try:
    32         try:
    30             poedit_cmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
    33             poedit_cmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
    31                                            'SOFTWARE\\Classes\\poedit\\shell\\open\\command')
    34                                            'SOFTWARE\\Classes\\poedit\\shell\\open\\command')
    32             poedit_path = poedit_cmd.replace('"%1"', '').strip().replace('"', '')
    35             cmd = re.findall(cmd_parser, poedit_cmd)
       
    36             dblquote_value,smpl_value = cmd[0]
       
    37             poedit_path = dblquote_value+smpl_value
    33         except OSError:
    38         except OSError:
    34             poedit_path = None
    39             poedit_path = None
    35 
    40 
    36     else:
    41     else:
    37         try:
    42         try: