From 0af633a36ce34fc2d80fb571f4b0e73233563827 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Sep 2011 17:44:45 +0000 Subject: move message.txt generator out of wm.py (which was loaded with blender always), into it own py script which runs on its own, also added this to 'make translations' target. --- GNUmakefile | 1 + po/update_mo.py | 1 + po/update_msg.py | 117 +++++++++++++++++++++++++++++ po/update_po.py | 1 + po/update_pot.py | 1 + release/scripts/startup/bl_operators/wm.py | 61 --------------- 6 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 po/update_msg.py diff --git a/GNUmakefile b/GNUmakefile index 1c8bb0f82a9..9915406e52c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -164,6 +164,7 @@ package_archive: # Other Targets # translations: + $(BUILD_DIR)/bin/blender --background --python po/update_msg.py python3 po/update_pot.py python3 po/update_po.py python3 po/update_mo.py diff --git a/po/update_mo.py b/po/update_mo.py index e0317f74dd7..eb4c2840e28 100755 --- a/po/update_mo.py +++ b/po/update_mo.py @@ -50,4 +50,5 @@ def main(): process.wait() if __name__ == "__main__": + print("\n\n *** Running %r *** \n" % __file__) main() diff --git a/po/update_msg.py b/po/update_msg.py new file mode 100644 index 00000000000..7bd372cf3ce --- /dev/null +++ b/po/update_msg.py @@ -0,0 +1,117 @@ +# $Id: +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +# + +# Write out messages.txt from blender + +# Execite: +# blender --background --python po/update_msg.py + +import os + +CURRENT_DIR = os.path.dirname(__file__) +SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, ".."))) + +FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt") + + +def dump_messages(): + import bpy + + # ------------------------------------------------------------------------- + # Function definitions + + def _putMessage(messages, msg): + if len(msg): + messages[msg] = True + + def _walkProperties(properties, messages): + import bpy + for prop in properties: + _putMessage(messages, prop.name) + _putMessage(messages, prop.description) + + if isinstance(prop, bpy.types.EnumProperty): + for item in prop.enum_items: + _putMessage(messages, item.name) + _putMessage(messages, item.description) + + def _walkRNA(bl_rna, messages): + if bl_rna.name and bl_rna.name != bl_rna.identifier: + _putMessage(messages, bl_rna.name) + + if bl_rna.description: + _putMessage(messages, bl_rna.description) + + _walkProperties(bl_rna.properties, messages) + + def _walkClass(cls, messages): + _walkRNA(cls.bl_rna, messages) + + def _walk_keymap_hierarchy(hier, messages): + for lvl in hier: + _putMessage(messages, lvl[0]) + + if lvl[3]: + _walk_keymap_hierarchy(lvl[3], messages) + + # ------------------------------------------------------------------------- + # Dump Messages + + messages = {} + + for cls in type(bpy.context).__base__.__subclasses__(): + _walkClass(cls, messages) + + for cls in bpy.types.Space.__subclasses__(): + _walkClass(cls, messages) + + for cls in bpy.types.Operator.__subclasses__(): + _walkClass(cls, messages) + + from bl_ui.space_userpref_keymap import KM_HIERARCHY + + _walk_keymap_hierarchy(KM_HIERARCHY, messages) + + message_file = open(FILE_NAME_MESSAGES, 'w') + message_file.writelines("\n".join(messages)) + message_file.close() + print("Written %d messages to: %r" % (len(messages), FILE_NAME_MESSAGES)) + + # XXX. what is this supposed to do, we wrote the file already??? + _walkClass(bpy.types.SpaceDopeSheetEditor, messages) + + return {'FINISHED'} + + +def main(): + + try: + import bpy + except ImportError: + print("This script must run from inside blender") + return + + dump_messages() + + +if __name__ == "__main__": + print("\n\n *** Running %r *** \n" % __file__) + main() diff --git a/po/update_po.py b/po/update_po.py index 88547760f67..d01d6a31613 100755 --- a/po/update_po.py +++ b/po/update_po.py @@ -49,4 +49,5 @@ def main(): if __name__ == "__main__": + print("\n\n *** Running %r *** \n" % __file__) main() diff --git a/po/update_pot.py b/po/update_pot.py index b0d77a3be03..b34b75f9740 100755 --- a/po/update_pot.py +++ b/po/update_pot.py @@ -92,4 +92,5 @@ def main(): if __name__ == "__main__": + print("\n\n *** Running %r *** \n" % __file__) main() diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index fae38eb1cef..861255f167f 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1144,67 +1144,6 @@ class WM_OT_sysinfo(Operator): return {'FINISHED'} -class WM_OT_get_messages(Operator): - bl_idname = "wm.get_messages" - bl_label = "Get Messages" - - def _putMessage(self, messages, msg): - if len(msg): - messages[msg] = True - - def _walkProperties(self, properties, messages): - for prop in properties: - self._putMessage(messages, prop.name) - self._putMessage(messages, prop.description) - - if isinstance(prop, bpy.types.EnumProperty): - for item in prop.enum_items: - self._putMessage(messages, item.name) - self._putMessage(messages, item.description) - - def _walkRNA(self, bl_rna, messages): - if bl_rna.name and bl_rna.name != bl_rna.identifier: - self._putMessage(messages, bl_rna.name) - - if bl_rna.description: - self._putMessage(messages, bl_rna.description) - - self._walkProperties(bl_rna.properties, messages) - - def _walkClass(self, cls, messages): - self._walkRNA(cls.bl_rna, messages) - - def _walk_keymap_hierarchy(self, hier, messages): - for lvl in hier: - self._putMessage(messages, lvl[0]) - - if lvl[3]: - self._walk_keymap_hierarchy(lvl[3], messages) - - def execute(self, context): - messages = {} - - for cls in type(bpy.context).__base__.__subclasses__(): - self._walkClass(cls, messages) - - for cls in bpy.types.Space.__subclasses__(): - self._walkClass(cls, messages) - - for cls in bpy.types.Operator.__subclasses__(): - self._walkClass(cls, messages) - - from bl_ui.space_userpref_keymap import KM_HIERARCHY - - self._walk_keymap_hierarchy(KM_HIERARCHY, messages) - - text = bpy.data.texts.new(name="messages.txt") - for message in messages: - text.write(message + "\n") - self._walkClass(bpy.types.SpaceDopeSheetEditor, messages) - - return {'FINISHED'} - - class WM_OT_copy_prev_settings(Operator): '''Copy settings from previous version''' bl_idname = "wm.copy_prev_settings" -- cgit v1.2.3