[Libreoffice-commits] core.git: solenv/bin

Christian Lohmaier (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 30 22:52:48 UTC 2021


 solenv/bin/hrcex    |   13 +++++++------
 solenv/bin/polib.py |    2 +-
 solenv/bin/uiex     |   10 +++++-----
 3 files changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 9dfd55dffc4cca6617b4ee67be9a8bfe96601c00
Author:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
AuthorDate: Mon Mar 29 15:55:45 2021 +0200
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Wed Mar 31 00:52:05 2021 +0200

    python3-ify hrcex & uiex (creation of pot files)
    
    Change-Id: I824c9ed536a1e852d6bd157fbd7d4766327b7bcd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113319
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/solenv/bin/hrcex b/solenv/bin/hrcex
index 54cef2626a19..0645f79fcb37 100755
--- a/solenv/bin/hrcex
+++ b/solenv/bin/hrcex
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 import polib
 import binascii
@@ -22,17 +22,18 @@ for o, a in myopts:
         ofile = a
 
 with open(ofile, "a") as output:
-    xgettext = Popen(["xgettext", "-C", "--add-comments", "--keyword=NC_:1c,2", "--keyword=NNC_:1c,2,3", "--from-code=UTF-8", "--no-wrap", ifile, "-o", "-"], stdout=PIPE)
+    xgettext = Popen(["xgettext", "-C", "--add-comments", "--keyword=NC_:1c,2", "--keyword=NNC_:1c,2,3", "--from-code=UTF-8", "--no-wrap", ifile, "-o", "-"], stdout=PIPE, encoding="UTF-8")
     # while overall format is c++, all of the strings use custom placeholders and don't follow c-format
     # esp. plain percent sign never is escaped explicitly
-    input = check_output(['sed', '-e', '/^#, c-format$/d'], stdin=xgettext.stdout)
+    input = check_output(['sed', '-e', '/^#, c-format$/d'], stdin=xgettext.stdout, encoding="UTF-8")
     xgettext.wait()
+    xgettext.stdout.close()
     po = polib.pofile(input)
     if len(po) != 0:
-        print >> output, ""
+        print("", file=output)
         for entry in po:
             keyid = entry.msgctxt + '|' + entry.msgid
-            print >> output, '#. ' + polib.genKeyId(keyid)
+            print('#. ' + polib.genKeyId(keyid), file=output)
             for i, occurrence in enumerate(entry.occurrences):
                 entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
-            print >> output, entry
+            print(entry, file=output)
diff --git a/solenv/bin/polib.py b/solenv/bin/polib.py
index 5ab421365376..092e7dfdb8b3 100644
--- a/solenv/bin/polib.py
+++ b/solenv/bin/polib.py
@@ -1858,7 +1858,7 @@ def wrap(text, width=70, **kwargs):
 # }}}
 
 def genKeyId(inkey):
-    crc = binascii.crc32(bytes(inkey)) & 0xffffffff
+    crc = binascii.crc32(bytes(inkey, encoding="UTF-8")) & 0xffffffff
     # Use simple ASCII characters, exclude I, l, 1 and O, 0 to avoid confusing IDs
     symbols = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";
     outkey = ""
diff --git a/solenv/bin/uiex b/solenv/bin/uiex
index ba47d8e2f9a8..b9344c429543 100755
--- a/solenv/bin/uiex
+++ b/solenv/bin/uiex
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 import polib
 import binascii
@@ -22,17 +22,17 @@ for o, a in myopts:
         ofile = a
 
 with open(ofile, "a") as output:
-    input = check_output(["xgettext", "--add-comments", "--no-wrap", ifile, "-o", "-"])
+    input = check_output(["xgettext", "--add-comments", "--no-wrap", ifile, "-o", "-"], encoding="UTF-8")
     po = polib.pofile(input)
     if len(po) != 0:
-        print >> output, ""
+        print("", file=output)
         for entry in po:
             # skip 'stock' entries like "cancel", "help", "ok", etc
             # l10ntools/source/localize.cxx will insert one entry for each stock per .po
             if entry.msgctxt == "stock":
                 continue
             keyid = entry.msgctxt + '|' + entry.msgid
-            print >> output, '#. ' + polib.genKeyId(keyid)
+            print('#. ' + polib.genKeyId(keyid), file=output)
             for i, occurrence in enumerate(entry.occurrences):
                 entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
-            print >> output, entry
+            print(entry, file=output)


More information about the Libreoffice-commits mailing list