aboutsummaryrefslogtreecommitdiffstats
path: root/docs/stylesheets/xslpo.py
diff options
context:
space:
mode:
authorYuri Chornoivan <yurchor@ukr.net>2020-11-02 09:49:14 +0200
committerYuri Chornoivan <yurchor@ukr.net>2020-11-02 09:49:14 +0200
commit36cae08d2df4b65307a26d8c89d72d9aa3ac3761 (patch)
treec75cea8289cc94081c64b17ac76611939d23a55b /docs/stylesheets/xslpo.py
parent17c47d470c34830cd97c2a5f07979dce89d1d58d (diff)
downloadtools-36cae08d2df4b65307a26d8c89d72d9aa3ac3761.tar
tools-36cae08d2df4b65307a26d8c89d72d9aa3ac3761.tar.gz
tools-36cae08d2df4b65307a26d8c89d72d9aa3ac3761.tar.bz2
tools-36cae08d2df4b65307a26d8c89d72d9aa3ac3761.tar.xz
tools-36cae08d2df4b65307a26d8c89d72d9aa3ac3761.zip
Port to Python 3
Diffstat (limited to 'docs/stylesheets/xslpo.py')
-rw-r--r--docs/stylesheets/xslpo.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/docs/stylesheets/xslpo.py b/docs/stylesheets/xslpo.py
index e723f2e1..51c4b199 100644
--- a/docs/stylesheets/xslpo.py
+++ b/docs/stylesheets/xslpo.py
@@ -1,14 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import errno, glob, polib, re, os, getopt, sys
from time import strftime
def usage():
- print '\nUsage: python %s [OPTION]' %os.path.basename(sys.argv[0])
- print ' generate pot catalogs and updates po files for xsl resources in the specified directory'
- print 'Options: -h, --help : usage'
- print ' -d <directory>, --directory <directory> : directory with xsl files'
+ print('\nUsage: python %s [OPTION]' %os.path.basename(sys.argv[0]))
+ print(' generate pot catalogs and updates po files for xsl resources in the specified directory')
+ print('Options: -h, --help : usage')
+ print(' -d <directory>, --directory <directory> : directory with xsl files')
sys.exit(2)
try:
opts, args = getopt.getopt(sys.argv[1:], "hd:", ["help", "directory="])
@@ -67,7 +67,7 @@ for langfile in files:
# Create localization directories if needed
try:
os.makedirs(podir)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
#open xsl file
@@ -80,16 +80,16 @@ for langfile in files:
msgkey, msg_id = enmessage.split('\" text=\"')
messages[msgkey] = msg_id
potentry = polib.POEntry(
- msgctxt = msgkey,
- msgid = msg_id.decode('utf-8'),
+ msgctxt = msgkey,
+ msgid = msg_id,
msgstr = '',
occurrences=[(langfile,'')]
)
if msg_id != '':
try:
- pot.append(potentry)
+ pot.append(potentry)
except ValueError:
- print '' # Should be some warning, ignore now
+ print('') # Should be some warning, ignore now
pot.save('po/doc_xsl.pot')
# Merge translations
@@ -119,11 +119,11 @@ for langfile in files:
if entry.translated():
translatedtext += u'\t\t<l:gentext key=\"%s\" text=\"%s\"/>\n' %(entry.msgctxt, entry.msgstr)
else:
- translatedtext += '\t\t<l:gentext key=\"%s\" text=\"%s\"/>\n' %(entry.msgctxt, messages[entry.msgctxt])
+ translatedtext += '\t\t<l:gentext key=\"%s\" text=\"%s\"/>\n' %(entry.msgctxt, messages[entry.msgctxt])
translatedtext += '\t</l:l10n>\n</l:i18n>'
text = text.replace('</l:i18n>', translatedtext)
# write file
- deskfile.write(text.encode('utf-8'))
+ deskfile.write(text)
deskfile.close()