[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2862] trunk/py/scripts/addons/modules/ extensions_framework: tabs -> spaces, no functional changes
Campbell Barton
ideasman42 at gmail.com
Wed Jan 4 05:22:27 CET 2012
Revision: 2862
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2862
Author: campbellbarton
Date: 2012-01-04 04:22:16 +0000 (Wed, 04 Jan 2012)
Log Message:
-----------
tabs -> spaces, no functional changes
Modified Paths:
--------------
trunk/py/scripts/addons/modules/extensions_framework/__init__.py
trunk/py/scripts/addons/modules/extensions_framework/ui.py
trunk/py/scripts/addons/modules/extensions_framework/util.py
trunk/py/scripts/addons/modules/extensions_framework/validate.py
Modified: trunk/py/scripts/addons/modules/extensions_framework/__init__.py
===================================================================
--- trunk/py/scripts/addons/modules/extensions_framework/__init__.py 2012-01-03 23:47:49 UTC (rev 2861)
+++ trunk/py/scripts/addons/modules/extensions_framework/__init__.py 2012-01-04 04:22:16 UTC (rev 2862)
@@ -33,339 +33,339 @@
del EF_OT_msg
def log(str, popup=False, module_name='EF'):
- """Print a message to the console, prefixed with the module_name
- and the current time. If the popup flag is True, the message will
- be raised in the UI as a warning using the operator bpy.ops.ef.msg.
-
- """
- print("[%s %s] %s" %
- (module_name, time.strftime('%Y-%b-%d %H:%M:%S'), str))
- if popup:
- bpy.ops.ef.msg(
- msg_type='WARNING',
- msg_text=str
- )
+ """Print a message to the console, prefixed with the module_name
+ and the current time. If the popup flag is True, the message will
+ be raised in the UI as a warning using the operator bpy.ops.ef.msg.
+ """
+ print("[%s %s] %s" %
+ (module_name, time.strftime('%Y-%b-%d %H:%M:%S'), str))
+ if popup:
+ bpy.ops.ef.msg(
+ msg_type='WARNING',
+ msg_text=str
+ )
+
added_property_cache = {}
def init_properties(obj, props, cache=True):
- """Initialise custom properties in the given object or type.
- The props list is described in the declarative_property_group
- class definition. If the cache flag is False, this function
- will attempt to redefine properties even if they have already been
- added.
-
- """
-
- if not obj in added_property_cache.keys():
- added_property_cache[obj] = []
-
- for prop in props:
- try:
- if cache and prop['attr'] in added_property_cache[obj]:
- continue
-
- if prop['type'] == 'bool':
- t = bpy.props.BoolProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","options","subtype","update"]}
- elif prop['type'] == 'bool_vector':
- t = bpy.props.BoolVectorProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","options","subtype","size",
- "update"]}
- elif prop['type'] == 'collection':
- t = bpy.props.CollectionProperty
- a = {k: v for k,v in prop.items() if k in ["ptype","name",
- "description","default","options"]}
- a['type'] = a['ptype']
- del a['ptype']
- elif prop['type'] == 'enum':
- t = bpy.props.EnumProperty
- a = {k: v for k,v in prop.items() if k in ["items","name",
- "description","default","options","update"]}
- elif prop['type'] == 'float':
- t = bpy.props.FloatProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","min","max","soft_min","soft_max",
- "step","precision","options","subtype","unit","update"]}
- elif prop['type'] == 'float_vector':
- t = bpy.props.FloatVectorProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","min","max","soft_min","soft_max",
- "step","precision","options","subtype","size","update"]}
- elif prop['type'] == 'int':
- t = bpy.props.IntProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","min","max","soft_min","soft_max",
- "step","options","subtype","update"]}
- elif prop['type'] == 'int_vector':
- t = bpy.props.IntVectorProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","min","max","soft_min","soft_max",
- "options","subtype","size","update"]}
- elif prop['type'] == 'pointer':
- t = bpy.props.PointerProperty
- a = {k: v for k,v in prop.items() if k in ["ptype", "name",
- "description","options","update"]}
- a['type'] = a['ptype']
- del a['ptype']
- elif prop['type'] == 'string':
- t = bpy.props.StringProperty
- a = {k: v for k,v in prop.items() if k in ["name",
- "description","default","maxlen","options","subtype",
- "update"]}
- else:
- continue
-
- setattr(obj, prop['attr'], t(**a))
-
- added_property_cache[obj].append(prop['attr'])
- except KeyError:
- # Silently skip invalid entries in props
- continue
+ """Initialise custom properties in the given object or type.
+ The props list is described in the declarative_property_group
+ class definition. If the cache flag is False, this function
+ will attempt to redefine properties even if they have already been
+ added.
+ """
+
+ if not obj in added_property_cache.keys():
+ added_property_cache[obj] = []
+
+ for prop in props:
+ try:
+ if cache and prop['attr'] in added_property_cache[obj]:
+ continue
+
+ if prop['type'] == 'bool':
+ t = bpy.props.BoolProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","options","subtype","update"]}
+ elif prop['type'] == 'bool_vector':
+ t = bpy.props.BoolVectorProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","options","subtype","size",
+ "update"]}
+ elif prop['type'] == 'collection':
+ t = bpy.props.CollectionProperty
+ a = {k: v for k,v in prop.items() if k in ["ptype","name",
+ "description","default","options"]}
+ a['type'] = a['ptype']
+ del a['ptype']
+ elif prop['type'] == 'enum':
+ t = bpy.props.EnumProperty
+ a = {k: v for k,v in prop.items() if k in ["items","name",
+ "description","default","options","update"]}
+ elif prop['type'] == 'float':
+ t = bpy.props.FloatProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","min","max","soft_min","soft_max",
+ "step","precision","options","subtype","unit","update"]}
+ elif prop['type'] == 'float_vector':
+ t = bpy.props.FloatVectorProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","min","max","soft_min","soft_max",
+ "step","precision","options","subtype","size","update"]}
+ elif prop['type'] == 'int':
+ t = bpy.props.IntProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","min","max","soft_min","soft_max",
+ "step","options","subtype","update"]}
+ elif prop['type'] == 'int_vector':
+ t = bpy.props.IntVectorProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","min","max","soft_min","soft_max",
+ "options","subtype","size","update"]}
+ elif prop['type'] == 'pointer':
+ t = bpy.props.PointerProperty
+ a = {k: v for k,v in prop.items() if k in ["ptype", "name",
+ "description","options","update"]}
+ a['type'] = a['ptype']
+ del a['ptype']
+ elif prop['type'] == 'string':
+ t = bpy.props.StringProperty
+ a = {k: v for k,v in prop.items() if k in ["name",
+ "description","default","maxlen","options","subtype",
+ "update"]}
+ else:
+ continue
+
+ setattr(obj, prop['attr'], t(**a))
+
+ added_property_cache[obj].append(prop['attr'])
+ except KeyError:
+ # Silently skip invalid entries in props
+ continue
+
class declarative_property_group(bpy.types.PropertyGroup):
- """A declarative_property_group describes a set of logically
- related properties, using a declarative style to list each
- property type, name, values, and other relevant information.
- The information provided for each property depends on the
- property's type.
-
- The properties list attribute in this class describes the
- properties present in this group.
-
- Some additional information about the properties in this group
- can be specified, so that a UI can be generated to display them.
- To that end, the controls list attribute and the visibility dict
- attribute are present here, to be read and interpreted by a
- property_group_renderer object.
- See extensions_framework.ui.property_group_renderer.
-
- """
-
- ef_initialised = False
-
- """This property tells extensions_framework which bpy.type(s)
- to attach this PropertyGroup to. If left as an empty list,
- it will not be attached to any type, but its properties will
- still be initialised. The type(s) given in the list should be
- a string, such as 'Scene'.
-
- """
- ef_attach_to = []
-
- @classmethod
- def initialise_properties(cls):
- """This is a function that should be called on
- sub-classes of declarative_property_group in order
- to ensure that they are initialised when the addon
- is loaded.
- the init_properties is called without caching here,
- as it is assumed that any addon calling this function
- will also call ef_remove_properties when it is
- unregistered.
-
- """
-
- if not cls.ef_initialised:
- for property_group_parent in cls.ef_attach_to:
- if property_group_parent is not None:
- prototype = getattr(bpy.types, property_group_parent)
- if not hasattr(prototype, cls.__name__):
- init_properties(prototype, [{
- 'type': 'pointer',
- 'attr': cls.__name__,
- 'ptype': cls,
- 'name': cls.__name__,
- 'description': cls.__name__
- }], cache=False)
-
- init_properties(cls, cls.properties, cache=False)
- cls.ef_initialised = True
-
- return cls
-
- @classmethod
- def register_initialise_properties(cls):
- """As ef_initialise_properties, but also registers the
- class with RNA. Note that this isn't a great idea
- because it's non-trivial to unregister the class, unless
- you keep track of it yourself.
- """
-
- bpy.utils.register_class(cls)
- cls.initialise_properties()
- return cls
-
- @classmethod
- def remove_properties(cls):
- """This is a function that should be called on
- sub-classes of declarative_property_group in order
- to ensure that they are un-initialised when the addon
- is unloaded.
-
- """
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list