Fix IOError
This commit is contained in:
parent
4a6fe4ba53
commit
7aa9b6c4a1
1 changed files with 33 additions and 27 deletions
|
@ -17,7 +17,7 @@ languages = [
|
||||||
'da_DK',
|
'da_DK',
|
||||||
'it_IT',
|
'it_IT',
|
||||||
'no_NO',
|
'no_NO',
|
||||||
'el_GR',
|
# 'el_GR',
|
||||||
'pl_PL',
|
'pl_PL',
|
||||||
# 'sv_SE',
|
# 'sv_SE',
|
||||||
'hu_HU',
|
'hu_HU',
|
||||||
|
@ -25,8 +25,8 @@ languages = [
|
||||||
'uk_UA',
|
'uk_UA',
|
||||||
]
|
]
|
||||||
|
|
||||||
tmp_file = r'K:\Private Dateien\Programming\plex\addon.xml'
|
tmp_file = r'C:\Users\Kat\Desktop\addon.xml'
|
||||||
PKC_dir = r'C:\Github\PlexKodiConnect'
|
PKC_dir = r'C:\Users\Kat\Documents\GitHub\PlexKodiConnect'
|
||||||
|
|
||||||
addon = {
|
addon = {
|
||||||
'msgctxt "#39703"': 'summary',
|
'msgctxt "#39703"': 'summary',
|
||||||
|
@ -56,29 +56,35 @@ def indent(elem, level=0):
|
||||||
|
|
||||||
root = etree.Element('addon')
|
root = etree.Element('addon')
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
with open(os.path.join(PKC_dir,
|
try:
|
||||||
'resources',
|
with open(os.path.join(PKC_dir,
|
||||||
'language',
|
'resources',
|
||||||
'resource.language.%s' % lang,
|
'language',
|
||||||
'strings.po'), 'rb') as f:
|
'resource.language.%s' % lang,
|
||||||
for line in f:
|
'strings.po'), 'rb') as f:
|
||||||
if line.strip() in addon:
|
for line in f:
|
||||||
msg = ''
|
if line.strip() in addon:
|
||||||
key = str(line.strip())
|
msg = ''
|
||||||
# Advance to the line msgstr ""
|
key = str(line.strip())
|
||||||
part = ''
|
# Advance to the line msgstr ""
|
||||||
while not part.startswith('msgstr'):
|
part = ''
|
||||||
part = next(f)
|
while not part.startswith('msgstr'):
|
||||||
msg += part.replace('msgstr', '').replace('"', '').strip()
|
part = next(f)
|
||||||
part = None
|
msg += part.replace('msgstr', '').replace('"', '').strip()
|
||||||
while part != '':
|
part = None
|
||||||
part = next(f).strip()
|
while part != '':
|
||||||
msg += part
|
part = next(f).strip()
|
||||||
msg = msg.replace('"', '').replace('\r', '').replace('\n', '')
|
msg += part
|
||||||
print(msg)
|
msg = msg.replace('"', '').replace('\r', '').replace('\n', '')
|
||||||
etree.SubElement(root,
|
print(msg)
|
||||||
addon[key],
|
etree.SubElement(root,
|
||||||
attrib={'lang': lang}).text = msg.decode('utf-8')
|
addon[key],
|
||||||
|
attrib={'lang': lang}).text = msg.decode('utf-8')
|
||||||
|
except IOError:
|
||||||
|
print('Missing file %s' % os.path.join(PKC_dir,
|
||||||
|
'resources',
|
||||||
|
'language',
|
||||||
|
'resource.language.%s' % lang,
|
||||||
|
'strings.po'))
|
||||||
indent(root)
|
indent(root)
|
||||||
etree.ElementTree(root).write(tmp_file, encoding="UTF-8")
|
etree.ElementTree(root).write(tmp_file, encoding="UTF-8")
|
||||||
|
|
Loading…
Reference in a new issue