[Bf-blender-cvs] [59b530ca181] master: Fix and workaround for i18n messages extraction code.

Bastien Montagne noreply at git.blender.org
Sun Dec 23 22:05:41 CET 2018


Commit: 59b530ca1810f109c3696814655e427d912ad6b7
Author: Bastien Montagne
Date:   Sun Dec 23 22:03:12 2018 +0100
Branches: master
https://developer.blender.org/rB59b530ca1810f109c3696814655e427d912ad6b7

Fix and workaround for i18n messages extraction code.

===================================================================

M	release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
M	release/scripts/modules/bl_i18n_utils/settings.py
M	release/scripts/modules/bl_i18n_utils/utils.py

===================================================================

diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index f22675b481f..0285a22a923 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -379,7 +379,8 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
         km_i18n_context = bpy.app.translations.contexts.id_windowmanager
         for lvl in hier:
             msgsrc = msgsrc_prev + "." + lvl[1]
-            process_msg(msgs, km_i18n_context, lvl[0], msgsrc, reports, None, settings)
+            if isinstance(lvl[0], str):  # Can be a function too, now, with tool system...
+                process_msg(msgs, km_i18n_context, lvl[0], msgsrc, reports, None, settings)
             if lvl[3]:
                 walk_keymap_hierarchy(lvl[3], msgsrc)
 
@@ -987,7 +988,7 @@ def main():
     args = parser.parse_args(argv)
 
     settings = settings_i18n.I18nSettings()
-    settings.from_json(args.settings)
+    settings.load(args.settings)
 
     if args.output:
         settings.FILE_NAME_POT = args.output
diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py
index 230c351d80c..8a0170b86d4 100644
--- a/release/scripts/modules/bl_i18n_utils/settings.py
+++ b/release/scripts/modules/bl_i18n_utils/settings.py
@@ -552,6 +552,8 @@ class I18nSettings:
             self.__dict__ = {uid: data for uid, data in globals().items() if not uid.startswith("_")}
         if isinstance(fname, str):
             if not os.path.isfile(fname):
+                # Assume it is already real JSon string...
+                self.from_json(fname)
                 return
             with open(fname) as f:
                 self.from_json(f.read())
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index 1db0beabb92..2116e39fd8e 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -180,26 +180,33 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False):
 
     prefs = bpy.context.preferences
     used_ext = {ext.module for ext in prefs.addons}
+    # XXX TEMP WORKAROUND
+    black_list = {"space_view3d_math_vis",
+                  "object_scatter"}
 
     ret = [
         mod for mod in addon_utils.modules()
-        if ((addons and mod.__name__ in addons) or
-            (not addons and addon_utils.module_bl_info(mod)["support"] in support))
+        if (((addons and mod.__name__ in addons) or
+            (not addons and addon_utils.module_bl_info(mod)["support"] in support)) and
+            (mod.__name__ not in black_list))
     ]
 
     if not check_only:
         for mod in ret:
-            module_name = mod.__name__
-            if disable:
-                if module_name not in used_ext:
-                    continue
-                print("    Disabling module ", module_name)
-                bpy.ops.wm.addon_disable(module=module_name)
-            else:
-                if module_name in used_ext:
-                    continue
-                print("    Enabling module ", module_name)
-                bpy.ops.wm.addon_enable(module=module_name)
+            try:
+                module_name = mod.__name__
+                if disable:
+                    if module_name not in used_ext:
+                        continue
+                    print("    Disabling module ", module_name)
+                    bpy.ops.wm.addon_disable(module=module_name)
+                else:
+                    if module_name in used_ext:
+                        continue
+                    print("    Enabling module ", module_name)
+                    bpy.ops.wm.addon_enable(module=module_name)
+            except Exception as e:  # XXX TEMP WORKAROUND
+                print(e)
 
         # XXX There are currently some problems with bpy/rna...
         #     *Very* tricky to solve!



More information about the Bf-blender-cvs mailing list