[Bf-blender-cvs] [2b485e2] master: Minor code simplification in previous commit.
Brecht Van Lommel
noreply at git.blender.org
Wed Apr 27 22:59:46 CEST 2016
Commit: 2b485e21f4d11e2313f97d6c1e34558b64e6f5a0
Author: Brecht Van Lommel
Date: Wed Apr 27 22:58:00 2016 +0200
Branches: master
https://developer.blender.org/rB2b485e21f4d11e2313f97d6c1e34558b64e6f5a0
Minor code simplification in previous commit.
===================================================================
M release/scripts/startup/nodeitems_builtins.py
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index b93cb85..092cd31 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -24,45 +24,35 @@ from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
# Subclasses for standard node types
-def alphabetical(items):
- # for builtin nodes the convention is to sort by name
- if isinstance(items, list):
- return sorted(items, key=lambda item: item.label().lower)
- return items
-
-class CompositorNodeCategory(NodeCategory):
+class SortedNodeCategory(NodeCategory):
def __init__(self, identifier, name, description="", items=None):
- super().__init__(identifier, name, description, alphabetical(items))
+ # for builtin nodes the convention is to sort by name
+ if isinstance(items, list):
+ items = sorted(items, key=lambda item: item.label.lower())
+
+ super().__init__(identifier, name, description, items)
+class CompositorNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.tree_type == 'CompositorNodeTree')
-class ShaderNewNodeCategory(NodeCategory):
- def __init__(self, identifier, name, description="", items=None):
- super().__init__(identifier, name, description, alphabetical(items))
-
+class ShaderNewNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.tree_type == 'ShaderNodeTree' and
context.scene.render.use_shading_nodes)
-class ShaderOldNodeCategory(NodeCategory):
- def __init__(self, identifier, name, description="", items=None):
- super().__init__(identifier, name, description, alphabetical(items))
-
+class ShaderOldNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.tree_type == 'ShaderNodeTree' and
not context.scene.render.use_shading_nodes)
-class TextureNodeCategory(NodeCategory):
- def __init__(self, identifier, name, description="", items=None):
- super().__init__(identifier, name, description, alphabetical(items))
-
+class TextureNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'TextureNodeTree'
More information about the Bf-blender-cvs
mailing list