[Libreoffice-commits] online.git: scripts/unocommands.py
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 24 12:08:06 UTC 2019
scripts/unocommands.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
New commits:
commit c1e04e406955c6f3bf186019ffee459c93f03330
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Oct 24 00:01:13 2019 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Oct 24 14:07:47 2019 +0200
scripts/unocommands.py: Switch to python3
Files not explicitly opened in binary mode are text files and thus
expect a 'str' arg for their write() method.
Python 2 is nearing its EOL and e.g. Debian has already
removed the python2-based 'python-polib' package previously
used here from its testing distribution.
I checked that running the commands
./scripts/unocommands.py --update . ../libreoffice
./scripts/unocommands.py --translate . ../libreoffice/translations
./scripts/unocommands.py --check .
still yields the same results as previously.
Change-Id: I39e1785d3c78416009420dd4c2be58bd1c3647c3
Reviewed-on: https://gerrit.libreoffice.org/81422
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
Tested-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/scripts/unocommands.py b/scripts/unocommands.py
index a28c3ab5d..e4dc45ef4 100755
--- a/scripts/unocommands.py
+++ b/scripts/unocommands.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
@@ -201,20 +201,19 @@ def writeUnocommandsJS(onlineDir, lofficeDir, menuCommands, contextCommands, too
descriptions = collectCommandsFromXCU(os.path.join(dir, file), descriptions, toolbarCommands, 'Label', type)
# output the unocommands.js
- f = open(onlineDir + '/loleaflet/src/unocommands.js', 'w')
+ f = open(onlineDir + '/loleaflet/src/unocommands.js', 'w', encoding='utf-8')
f.write('''// Don't modify, generated using unocommands.py
var unoCommandsArray = {\n''')
for key in sorted(descriptions.keys()):
- #f.write((' ' + key + ": _('" + descriptions[key] + "'),\n").encode('utf-8'))
- f.write(('\t' + key + ':{').encode('utf-8'))
+ f.write('\t' + key + ':{')
for type in sorted(descriptions[key].keys()):
- f.write((type + ':{').encode('utf-8'))
+ f.write(type + ':{')
for menuType in sorted(descriptions[key][type].keys()):
- f.write((menuType + ":_('" + descriptions[key][type][menuType] + "'),").encode('utf-8'))
- f.write(('},').encode('utf-8'))
- f.write(('},\n').encode('utf-8'))
+ f.write(menuType + ":_('" + descriptions[key][type][menuType] + "'),")
+ f.write('},')
+ f.write('},\n')
f.write('''};
@@ -258,10 +257,9 @@ window._UNO = function(string, component, isContext) {
def parseUnocommandsJS(onlineDir):
strings = {}
- f = open(onlineDir + '/loleaflet/src/unocommands.js', 'r')
+ f = open(onlineDir + '/loleaflet/src/unocommands.js', 'r', encoding='utf-8')
readingCommands = False
for line in f:
- line = line.decode('utf-8')
m = re.match(r"\t([^:]*):.*", line)
if m:
command = m.group(1)
@@ -296,7 +294,7 @@ def writeTranslations(onlineDir, translationsDir, strings):
if text == entry.msgid:
translations[entry.msgid] = entry.msgstr
- f = open(onlineDir + '/loleaflet/l10n/uno/' + lang + '.json', 'w')
+ f = open(onlineDir + '/loleaflet/l10n/uno/' + lang + '.json', 'w', encoding='utf-8')
f.write('{\n')
writeComma = False
@@ -305,7 +303,7 @@ def writeTranslations(onlineDir, translationsDir, strings):
f.write(',\n')
else:
writeComma = True
- f.write(('"' + key.replace('"','\\\"') + '":"' + translations[key].replace('"','\\\"') + '"').encode('utf-8'))
+ f.write('"' + key.replace('"','\\\"') + '":"' + translations[key].replace('"','\\\"') + '"')
f.write('\n}\n')
More information about the Libreoffice-commits
mailing list