diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-05 07:39:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-05 07:39:22 +0400 |
commit | f7737153e6c052c53d638d7bce986e4acbf47aad (patch) | |
tree | a1a456a6ea8e1a349c4ae9e36140915e17aa8aff /po | |
parent | 3b8de8db31a98ee2cabf783c5d58888cadab1d53 (diff) |
filter RNA classes for translation (removes over 1300 lines from messages.txt)
- omit operators tagged as INTERNAL
- omit classes for internal use: Event, Context, Property, Function, Window.
Diffstat (limited to 'po')
-rw-r--r-- | po/update_msg.py | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/po/update_msg.py b/po/update_msg.py index 9fc9967146d..e91371c1755 100644 --- a/po/update_msg.py +++ b/po/update_msg.py @@ -17,7 +17,7 @@ # # ***** END GPL LICENSE BLOCK ***** -# <pep8 compliant> +# <pep8-80 compliant> # Write out messages.txt from blender @@ -36,6 +36,71 @@ COMMENT_PREFIX = "#~ " def dump_messages_rna(messages): import bpy + def classBlackList(): + blacklist_rna_class = [ + # core classes + "Context", "Event", "Function", "UILayout", + "BlendData", + # registerable classes + "Panel", "Menu", "Header", "RenderEngine", + "Operator", "OperatorMacro", "UnknownType" + # window classes + "WindowManager", "Window" + ] + + # --------------------------------------------------------------------- + # Collect internal operators + + # extend with all internal operators + # note that this uses internal api introspection functions + # all possible operator names + op_names = list(sorted(set( + [cls.bl_rna.identifier for cls in + bpy.types.OperatorProperties.__subclasses__()] + + [cls.bl_rna.identifier for cls in + bpy.types.Operator.__subclasses__()] + + [cls.bl_rna.identifier for cls in + bpy.types.OperatorMacro.__subclasses__()] + ))) + + get_inatance = __import__("_bpy").ops.get_instance + path_resolve = type(bpy.context).__base__.path_resolve + for idname in op_names: + op = get_inatance(idname) + if 'INTERNAL' in path_resolve(op, "bl_options"): + blacklist_rna_class.append(idname) + + # --------------------------------------------------------------------- + # Collect builtin classes we dont need to doc + blacklist_rna_class.append("Property") + blacklist_rna_class.extend( + [cls.__name__ for cls in + bpy.types.Property.__subclasses__()]) + + # --------------------------------------------------------------------- + # Collect classes which are attached to collections, these are api + # access only. + collection_props = set() + for cls_id in dir(bpy.types): + cls = getattr(bpy.types, cls_id) + for prop in cls.bl_rna.properties: + if prop.type == 'COLLECTION': + prop_cls = prop.srna + if prop_cls is not None: + collection_props.add(prop_cls.identifier) + blacklist_rna_class.extend(sorted(collection_props)) + + return blacklist_rna_class + + blacklist_rna_class = classBlackList() + + def filterRNA(bl_rna): + id = bl_rna.identifier + if id in blacklist_rna_class: + print(" skipping", id) + return True + return False + # ------------------------------------------------------------------------- # Function definitions @@ -70,6 +135,10 @@ def dump_messages_rna(messages): messages.setdefault(item.description, []).append(msgsrc) def walkRNA(bl_rna): + + if filterRNA(bl_rna): + return + msgsrc = "bpy.types.%s" % bl_rna.identifier if bl_rna.name and bl_rna.name != bl_rna.identifier: |