[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51317] trunk/blender/release/scripts/ modules/bl_i18n_utils: Few minor fixes to i18n tools ( mostly use ordered dicts too for "xgettexted" messages...).

Bastien Montagne montagne29 at wanadoo.fr
Sun Oct 14 16:18:31 CEST 2012


Revision: 51317
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51317
Author:   mont29
Date:     2012-10-14 14:18:30 +0000 (Sun, 14 Oct 2012)
Log Message:
-----------
Few minor fixes to i18n tools (mostly use ordered dicts too for "xgettexted" messages...).

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bl_i18n_utils/update_pot.py
    trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py

Modified: trunk/blender/release/scripts/modules/bl_i18n_utils/update_pot.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/update_pot.py	2012-10-14 13:21:40 UTC (rev 51316)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/update_pot.py	2012-10-14 14:18:30 UTC (rev 51317)
@@ -117,28 +117,30 @@
 
 
 def py_xgettext(messages):
+    forbidden = set()
+    forced = set()
     with open(SRC_POTFILES) as src:
-        forbidden = set()
-        forced = set()
         for l in src:
             if l[0] == '-':
                 forbidden.add(l[1:].rstrip('\n'))
             elif l[0] != '#':
                 forced.add(l.rstrip('\n'))
-        for root, dirs, files in os.walk(POTFILES_DIR):
-            if "/.svn" in root:
+    for root, dirs, files in os.walk(POTFILES_DIR):
+        if "/.svn" in root:
+            continue
+        for fname in files:
+            if os.path.splitext(fname)[1] not in PYGETTEXT_ALLOWED_EXTS:
                 continue
-            for fname in files:
-                if os.path.splitext(fname)[1] not in PYGETTEXT_ALLOWED_EXTS:
-                    continue
-                path = os.path.join(root, fname)
-                rel_path = os.path.relpath(path, SOURCE_DIR)
-                if rel_path in forbidden | forced:
-                    continue
-                check_file(path, rel_path, messages)
-        for path in forced:
-            if os.path.exists(path):
-                check_file(os.path.join(SOURCE_DIR, path), path, messages)
+            path = os.path.join(root, fname)
+            rel_path = os.path.relpath(path, SOURCE_DIR)
+            if rel_path in forbidden:
+                continue
+            elif rel_path in forced:
+                forced.remove(rel_path)
+            check_file(path, rel_path, messages)
+    for path in forced:
+        if os.path.exists(path):
+            check_file(os.path.join(SOURCE_DIR, path), path, messages)
 
 
 # Spell checking!
@@ -250,7 +252,7 @@
 
     print("Running fake py gettext…")
     # Not using any more xgettext, simpler to do it ourself!
-    messages = {}
+    messages = utils.new_messages()
     py_xgettext(messages)
     print("Finished, found {} messages.".format(len(messages)))
 
@@ -268,7 +270,7 @@
 
     # add messages collected automatically from RNA
     print("\tMerging RNA messages from {}…".format(FILE_NAME_MESSAGES))
-    messages = {}
+    messages = utils.new_messages()
     with open(FILE_NAME_MESSAGES, encoding="utf-8") as f:
         srcs = []
         context = ""

Modified: trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py	2012-10-14 13:21:40 UTC (rev 51316)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py	2012-10-14 14:18:30 UTC (rev 51317)
@@ -41,6 +41,10 @@
     return len(msgid) > 30
 
 
+def new_messages():
+    return getattr(collections, 'OrderedDict', dict)()
+
+
 def parse_messages(fname):
     """
     Returns a tupple (messages, states, stats).
@@ -78,7 +82,7 @@
     msgctxt_lines = []
     comment_lines = []
 
-    messages = getattr(collections, 'OrderedDict', dict)()
+    messages = new_messages()
     translated_messages = set()
     fuzzy_messages = set()
     commented_messages = set()
@@ -282,7 +286,7 @@
     """Generate an empty messages & state data (only header if present!)."""
     header_key = ("", "")
 
-    messages = getattr(collections, 'OrderedDict', dict)()
+    messages = new_messages()
     messages[header_key] = {
         "msgid_lines": [""],
         "msgctxt_lines": [],




More information about the Bf-blender-cvs mailing list