From 337b718695c8b31dadc22438b9f1af40d225e0ad Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 9 Feb 2016 12:44:06 +0100 Subject: Fix T47371 - add access to 'static' enum items. Some dynamic enums, which do not need a valid context pointer, have their 'itemf' callback always called. This is annoying for introspection tools (like the ones generating translations, or API documentation), because it means they never have access to all possible options (enum items). So now, there is also an `enum_items_static` accessor to get only statically-defined enum items. Note: only i18n tools take advantage of this currently, others are still to be updated. Reviewers: campbellbarton, sergey Differential Revision: https://developer.blender.org/D1782 --- release/scripts/modules/bl_i18n_utils/bl_extract_messages.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'release') 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 ce09b156d85..5a3eda567be 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -322,8 +322,20 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): process_msg(msgs, default_context, prop.description, msgsrc, reports, check_ctxt_rna_tip, settings) if isinstance(prop, bpy.types.EnumProperty): + done_items = set() for item in prop.enum_items: msgsrc = "bpy.types.{}.{}:'{}'".format(bl_rna.identifier, prop.identifier, item.identifier) + done_items.add(item.identifier) + if item.name and item.name != item.identifier: + process_msg(msgs, msgctxt, item.name, msgsrc, reports, check_ctxt_rna, settings) + if item.description: + process_msg(msgs, default_context, item.description, msgsrc, reports, check_ctxt_rna_tip, + settings) + for item in prop.enum_items_static: + if item.identifier in done_items: + continue + msgsrc = "bpy.types.{}.{}:'{}'".format(bl_rna.identifier, prop.identifier, item.identifier) + done_items.add(item.identifier) if item.name and item.name != item.identifier: process_msg(msgs, msgctxt, item.name, msgsrc, reports, check_ctxt_rna, settings) if item.description: -- cgit v1.2.3