From 1cc5dcfcb33fef4067904c4b93ee9446f3167f6b Mon Sep 17 00:00:00 2001 From: Doug Hammond <doughammond@hamsterfight.co.uk> Date: Sat, 12 Feb 2011 18:31:47 +0000 Subject: [PATCH] extensions_framework: Add optional bl_info parameter to Addon class contstructor, useful for making bl_idname and bl_label strings for versioned addons --- modules/extensions_framework/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/extensions_framework/__init__.py b/modules/extensions_framework/__init__.py index f8ce0d35b..bf79d5c42 100644 --- a/modules/extensions_framework/__init__.py +++ b/modules/extensions_framework/__init__.py @@ -273,10 +273,26 @@ class declarative_property_group(bpy.types.IDPropertyGroup): class Addon(object): """A list of classes registered by this addon""" + static_addon_count = 0 + + addon_serial = 0 addon_classes = None + bl_info = None - def __init__(self): + def __init__(self, bl_info=None): self.addon_classes = [] + self.bl_info = bl_info + self.addon_serial = Addon.static_addon_count + + Addon.static_addon_count += 1 + + def bl_infos(self): + if self.bl_info: + BL_VERSION = '.'.join(['%s'%v for v in self.bl_info['version']]).lower() + BL_IDNAME = self.bl_info['name'].lower() + '-' + BL_VERSION + return BL_VERSION, BL_IDNAME + else: + return '0', 'Addon-%03d'%self.addon_serial def addon_register_class(self, cls): """This method is designed to be used as a decorator on RNA-registerable -- GitLab