Some cleanup, and update to make those files usable both as self-executables and...
authorBastien Montagne <montagne29@wanadoo.fr>
Sun, 8 Jul 2012 17:10:10 +0000 (17:10 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Sun, 8 Jul 2012 17:10:10 +0000 (17:10 +0000)
Also updated update_mo to allwo specifying a custom po/mo file.

release/scripts/modules/bl_i18n_utils/check_po.py
release/scripts/modules/bl_i18n_utils/clean_po.py
release/scripts/modules/bl_i18n_utils/import_po_from_branches.py
release/scripts/modules/bl_i18n_utils/merge_po.py
release/scripts/modules/bl_i18n_utils/rtl_preprocess.py
release/scripts/modules/bl_i18n_utils/update_branches.py
release/scripts/modules/bl_i18n_utils/update_mo.py
release/scripts/modules/bl_i18n_utils/update_msg.py
release/scripts/modules/bl_i18n_utils/update_po.py
release/scripts/modules/bl_i18n_utils/update_pot.py
release/scripts/modules/bl_i18n_utils/update_trunk.py

index a688d38df88d1cfc7c73f19bb65e3bcbfca7f848..b669a9ddff252fe3c9e622b0a002aea9d1904202 100755 (executable)
@@ -26,8 +26,11 @@ import os
 import sys
 from codecs import open
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
 
 TRUNK_PO_DIR = settings.TRUNK_PO_DIR
 BRANCHES_DIR = settings.BRANCHES_DIR
index 7e91b41065c8d0f2614a16afd046a94136041deb..f0b8dd6b1d2e63436c2518ae00504525380a8fbd 100755 (executable)
 import os
 import sys
 import collections
-from codecs import open
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
+
 
 TRUNK_PO_DIR = settings.TRUNK_PO_DIR
 BRANCHES_DIR = settings.BRANCHES_DIR
index 4739a98920f0f33e8ff8d11c155894a0d056dc00..cbbef17b37dce3395fbbf93c3264751ec7ea885f 100755 (executable)
@@ -28,9 +28,12 @@ import sys
 import subprocess
 from codecs import open
 
-import settings
-import utils
-import rtl_preprocess
+try:
+    import settings
+    import utils
+    import rtl_preprocess
+except:
+    from . import (settings, utils, rtl_preprocess)
 
 
 TRUNK_PO_DIR = settings.TRUNK_PO_DIR
index 1a55cd670b061cd8a9fce779177ab8807119c153..b09e4daefbc917b98790f039767bd393468f8f0c 100755 (executable)
 # never merged from sources.
 
 import sys
-from codecs import open
 
-import utils
+try:
+    import utils
+except:
+    from . import utils
 
 
 def main():
index c6fc5fc787e5558cc754345a36a86fdc4e5f8d51..9b2ee9839524a10ebdd67f12934fa3e6b75a58bf 100755 (executable)
 import sys
 import ctypes
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
+
 
 FRIBIDI_LIB = settings.FRIBIDI_LIB
 
index 1a856b1494407e3ef81e4139deb7093bc8551b26..6626fa937a6b3754582c038342f052010587b4f4 100755 (executable)
@@ -30,7 +30,11 @@ import os
 import sys
 import tempfile
 
-import settings
+try:
+    import settings
+except:
+    from . import settings
+
 
 PY3 = settings.PYTHON3_EXEC
 
index 9804eb8ce340010f1aa4a6a752eb24b763128cbc..1b415e7bd7cb7ad0ac7f8cdc04dcb57d4bde4bf0 100755 (executable)
@@ -26,8 +26,11 @@ import subprocess
 import os
 import sys
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
 
 
 GETTEXT_MSGFMT_EXECUTABLE = settings.GETTEXT_MSGFMT_EXECUTABLE
@@ -39,17 +42,19 @@ TRUNK_PO_DIR = settings.TRUNK_PO_DIR
 DOMAIN = settings.DOMAIN
 
 
-def process_po(po, lang):
-    mo_dir = os.path.join(TRUNK_MO_DIR, lang, "LC_MESSAGES")
+def process_po(po, lang, mo=None):
+    if not mo:
+        mo_dir = os.path.join(TRUNK_MO_DIR, lang, "LC_MESSAGES")
+        # Create dirs if not existing!
+        if not os.path.isdir(mo_dir):
+            os.makedirs(mo_dir, exist_ok = True)
 
-    # Create dirs if not existing!
-    os.makedirs(mo_dir, exist_ok = True)
     # show stats
     cmd = (GETTEXT_MSGFMT_EXECUTABLE,
         "--statistics",
         po,
         "-o",
-        os.path.join(mo_dir, ".".join((DOMAIN, "mo"))),
+        mo or os.path.join(mo_dir, ".".join((DOMAIN, "mo"))),
         )
 
     print("Running ", " ".join(cmd))
@@ -64,11 +69,18 @@ def main():
                                                  "under {}.".format(TRUNK_MO_DIR))
     parser.add_argument('langs', metavar='ISO_code', nargs='*',
                         help="Restrict processed languages to those.")
+    parser.add_argument('po', help="Only process that po file (implies --mo).")
+    parser.add_argument('mo', help="Mo file to generate (implies --po).")
     args = parser.parse_args()
 
     ret = 0
 
-    if args.langs:
+    if args.po and args.mo:
+        if os.path.exists(args.po):
+            t = process_po(args.po, None, args.mo)
+            if t:
+                ret = t
+    elif args.langs:
         for lang in args.langs:
             po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po")))
             if os.path.exists(po):
index e5154632cfed4256383d10f1ef652b86eada483a..c1b0d636655f644c7c980526d32890876964465b 100755 (executable)
@@ -26,7 +26,10 @@ import os
 import sys
 import subprocess
 
-import settings
+try:
+    import settings
+except:
+    from . import settings
 
 
 BLENDER_ARGS = [
index c4e980aad2a870b04cfc08c5b4c73cf2f953a000..d098b50e907fa75a467d9bd94ac571ab6fdc31e2 100755 (executable)
@@ -28,8 +28,12 @@ import sys
 from codecs import open
 import shutil
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
+
 
 GETTEXT_MSGMERGE_EXECUTABLE = settings.GETTEXT_MSGMERGE_EXECUTABLE
 BRANCHES_DIR  = settings.BRANCHES_DIR
index 58c924cade49d10b537a1b832498b1c781e43080..ca5d156be9b84beeb8d3573693e48ca269fa7005 100755 (executable)
@@ -31,8 +31,11 @@ import argparse
 import time
 import pickle
 
-import settings
-import utils
+try:
+    import settings
+    import utils
+except:
+    from . import (settings, utils)
 
 
 COMMENT_PREFIX = settings.COMMENT_PREFIX
index f4a2e0b3f8ff767f3266e9f17c4e95325f20c9fb..5e0ceab387c87160c643004d8e7bf4ac3ae34535 100755 (executable)
@@ -33,7 +33,10 @@ import os
 import sys
 import shutil
 
-import settings
+try:
+    import settings
+except:
+    from . import settings
 
 TRUNK_PO_DIR = settings.TRUNK_PO_DIR
 TRUNK_MO_DIR = settings.TRUNK_MO_DIR