[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4437] contrib/py/scripts/addons/ node_efficiency_tools.py: pep8 cleanup: also minor changes to match conventions of scripts in trunk.

Campbell Barton ideasman42 at gmail.com
Wed Mar 27 19:19:22 CET 2013


Revision: 4437
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4437
Author:   campbellbarton
Date:     2013-03-27 18:19:22 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
pep8 cleanup: also minor changes to match conventions of scripts in trunk.

Modified Paths:
--------------
    contrib/py/scripts/addons/node_efficiency_tools.py

Modified: contrib/py/scripts/addons/node_efficiency_tools.py
===================================================================
--- contrib/py/scripts/addons/node_efficiency_tools.py	2013-03-27 11:33:56 UTC (rev 4436)
+++ contrib/py/scripts/addons/node_efficiency_tools.py	2013-03-27 18:19:22 UTC (rev 4437)
@@ -23,7 +23,7 @@
     'blender': (2, 6, 6),
     'location': "Node Editor Properties Panel (Ctrl-SPACE)",
     'description': "Nodes Efficiency Tools",
-    'warning': "", 
+    'warning': "",
     'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Nodes/Nodes_Efficiency_Tools",
     'tracker_url': "http://projects.blender.org/tracker/?func=detail&atid=468&aid=33543&group_id=153",
     'category': "Node",
@@ -42,7 +42,7 @@
 # rl_outputs entry = (render_pass, rl_output_name, exr_output_name, in_internal, in_cycles)
 rl_outputs = (
     ('use_pass_ambient_occlusion', 'AO', 'AO', True, True),
-    ('use_pass_color', 'Color', 'Color',True, False),
+    ('use_pass_color', 'Color', 'Color', True, False),
     ('use_pass_combined', 'Image', 'Combined', True, True),
     ('use_pass_diffuse', 'Diffuse', 'Diffuse', True, False),
     ('use_pass_diffuse_color', 'Diffuse Color', 'DiffCol', False, True),
@@ -135,6 +135,7 @@
     ('ShaderNodeHoldout', 'HOLDOUT', 'Holdout'),
     )
 
+
 def get_nodes_links(context):
     space = context.space_data
     tree = space.node_tree
@@ -154,7 +155,7 @@
         tree = active.node_tree
         nodes = tree.nodes
         links = tree.links
-    
+
     return nodes, links
 
 
@@ -170,23 +171,23 @@
     bl_label = "Merge Nodes"
     bl_description = "Merge Selected Nodes"
     bl_options = {'REGISTER', 'UNDO'}
-    
+
     mode = EnumProperty(
-        name = "mode",
-        description = "All possible blend types and math operations",
-        items = blend_types + [op for op in operations if op not in blend_types],
-        )
+            name="mode",
+            description="All possible blend types and math operations",
+            items=blend_types + [op for op in operations if op not in blend_types],
+            )
     merge_type = EnumProperty(
-        name = "merge type",
-        description = "Type of Merge to be used",
-        items = [
-            ('AUTO', 'Auto', 'Automatic Output Type Detection'),
-            ('SHADER', 'Shader', 'Merge using ADD or MIX Shader'),
-            ('MIX', 'Mix Node', 'Merge using Mix Nodes'),
-            ('MATH', 'Math Node', 'Merge using Math Nodes'),
-            ],
-        )
-    
+            name="merge type",
+            description="Type of Merge to be used",
+            items=(
+                ('AUTO', 'Auto', 'Automatic Output Type Detection'),
+                ('SHADER', 'Shader', 'Merge using ADD or MIX Shader'),
+                ('MIX', 'Mix Node', 'Merge using Mix Nodes'),
+                ('MATH', 'Math Node', 'Merge using Math Nodes'),
+                ),
+            )
+
     def execute(self, context):
         tree_type = context.space_data.node_tree.type
         if tree_type == 'COMPOSITING':
@@ -199,15 +200,15 @@
         selected_mix = []  # entry = [index, loc]
         selected_shader = []  # entry = [index, loc]
         selected_math = []  # entry = [index, loc]
-        
+
         for i, node in enumerate(nodes):
             if node.select and node.outputs:
                 if merge_type == 'AUTO':
                     for (type, types_list, dst) in (
-                        ('SHADER', merge_shaders, selected_shader),
-                        ('RGBA', [t[0] for t in blend_types], selected_mix),
-                        ('VALUE', [t[0] for t in operations], selected_math),
-                        ):
+                            ('SHADER', merge_shaders, selected_shader),
+                            ('RGBA', [t[0] for t in blend_types], selected_mix),
+                            ('VALUE', [t[0] for t in operations], selected_math),
+                            ):
                         output_type = node.outputs[0].type
                         valid_mode = mode in types_list
                         # When mode is 'MIX' use mix node for both 'RGBA' and 'VALUE' output types.
@@ -222,10 +223,10 @@
                             dst.append([i, node.location.x, node.location.y])
                 else:
                     for (type, types_list, dst) in (
-                        ('SHADER', merge_shaders, selected_shader),
-                        ('MIX', [t[0] for t in blend_types], selected_mix),
-                        ('MATH', [t[0] for t in operations], selected_math),
-                        ):
+                            ('SHADER', merge_shaders, selected_shader),
+                            ('MIX', [t[0] for t in blend_types], selected_mix),
+                            ('MATH', [t[0] for t in operations], selected_math),
+                            ):
                         if merge_type == type and mode in types_list:
                             dst.append([i, node.location.x, node.location.y])
         # When nodes with output kinds 'RGBA' and 'VALUE' are selected at the same time
@@ -234,20 +235,20 @@
         if selected_mix and selected_math and merge_type == 'AUTO':
             selected_mix += selected_math
             selected_math = []
-        
+
         for nodes_list in [selected_mix, selected_shader, selected_math]:
             if nodes_list:
                 count_before = len(nodes)
                 # sort list by loc_x - reversed
-                nodes_list.sort(key = lambda k: k[1], reverse = True)
+                nodes_list.sort(key=lambda k: k[1], reverse=True)
                 # get maximum loc_x
                 loc_x = nodes_list[0][1] + 350.0
-                nodes_list.sort(key = lambda k: k[2], reverse = True)
+                nodes_list.sort(key=lambda k: k[2], reverse=True)
                 loc_y = nodes_list[len(nodes_list) - 1][2]
                 offset_y = 40.0
                 if nodes_list == selected_shader:
                     offset_y = 150.0
-                the_range = len(nodes_list)-1
+                the_range = len(nodes_list) - 1
                 do_hide = True
                 if len(nodes_list) == 1:
                     the_range = 1
@@ -294,15 +295,15 @@
                 # add links between added ADD nodes and between selected and ADD nodes
                 for i in range(count_adds):
                     if i < count_adds - 1:
-                        links.new(nodes[index-1].inputs[first], nodes[index].outputs[0])
+                        links.new(nodes[index - 1].inputs[first], nodes[index].outputs[0])
                     if len(nodes_list) > 1:
-                        links.new(nodes[index].inputs[second], nodes[nodes_list[i+1][0]].outputs[0])
+                        links.new(nodes[index].inputs[second], nodes[nodes_list[i + 1][0]].outputs[0])
                     index -= 1
-                # set "last" of added nodes as active    
+                # set "last" of added nodes as active
                 nodes.active = nodes[count_before]
                 for i, x, y in nodes_list:
                     nodes[i].select = False
-                    
+
         return {'FINISHED'}
 
 
@@ -311,16 +312,16 @@
     bl_label = "Batch Change"
     bl_description = "Batch Change Blend Type and Math Operation"
     bl_options = {'REGISTER', 'UNDO'}
-    
+
     blend_type = EnumProperty(
-        name = "Blend Type",
-        items = blend_types + navs,
-        )
+            name="Blend Type",
+            items=blend_types + navs,
+            )
     operation = EnumProperty(
-        name = "Operation",
-        items = operations + navs,
-        )
-        
+            name="Operation",
+            items=operations + navs,
+            )
+
     def execute(self, context):
         nodes, links = get_nodes_links(context)
         blend_type = self.blend_type
@@ -344,7 +345,7 @@
                             node.blend_type = blend_types[len(blend_types) - 1][0]
                         else:
                             node.blend_type = blend_types[index - 1][0]
-                                                        
+
             if node.type == 'MATH':
                 if not operation in [nav[0] for nav in navs]:
                     node.operation = operation
@@ -373,12 +374,12 @@
     bl_label = "Change Factor"
     bl_description = "Change Factors of Mix Nodes and Mix Shader Nodes"
     bl_options = {'REGISTER', 'UNDO'}
-    
+
     # option: Change factor.
     # If option is 1.0 or 0.0 - set to 1.0 or 0.0
     # Else - change factor by option value.
     option = FloatProperty()
-    
+
     def execute(self, context):
         nodes, links = get_nodes_links(context)
         option = self.option
@@ -387,7 +388,7 @@
             if node.select:
                 if node.type in {'MIX_RGB', 'MIX_SHADER'}:
                     selected.append(si)
-                
+
         for si in selected:
             fac = nodes[si].inputs[0]
             nodes[si].hide = False
@@ -395,7 +396,7 @@
                 fac.default_value = option
             else:
                 fac.default_value += option
-        
+
         return {'FINISHED'}
 
 
@@ -404,7 +405,7 @@
     bl_label = "Copy Settings"
     bl_description = "Copy Settings of Active Node to Selected Nodes"
     bl_options = {'REGISTER', 'UNDO'}
-    
+
     @classmethod
     def poll(cls, context):
         space = context.space_data
@@ -416,7 +417,7 @@
                 ):
             valid = True
         return valid
-    
+
     def execute(self, context):
         nodes, links = get_nodes_links(context)
         selected = [n for n in nodes if n.select]
@@ -424,11 +425,11 @@
         active = nodes.active
         if active.select:
             reselect.append(active)
-        
+
         for node in selected:
             if node.type == active.type and node != active:
                 # duplicate active, relink links as in 'node', append copy to 'reselect', delete node
-                bpy.ops.node.select_all(action = 'DESELECT')
+                bpy.ops.node.select_all(action='DESELECT')
                 nodes.active = active
                 active.select = True
                 bpy.ops.node.duplicate()
@@ -462,18 +463,18 @@
                         out_links = output.links
                         for link in out_links:
                             links.new(copied.outputs[out], link.to_socket)

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list