[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38682] trunk/blender/release/scripts/ startup/bl_operators: style changes for operator scripts & some pep8 edits.

Campbell Barton ideasman42 at gmail.com
Mon Jul 25 08:40:16 CEST 2011


Revision: 38682
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38682
Author:   campbellbarton
Date:     2011-07-25 06:40:16 +0000 (Mon, 25 Jul 2011)
Log Message:
-----------
style changes for operator scripts & some pep8 edits.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/mesh.py
    trunk/blender/release/scripts/startup/bl_operators/object.py
    trunk/blender/release/scripts/startup/bl_operators/object_align.py
    trunk/blender/release/scripts/startup/bl_operators/object_randomize_transform.py
    trunk/blender/release/scripts/startup/bl_operators/presets.py

Modified: trunk/blender/release/scripts/startup/bl_operators/mesh.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/mesh.py	2011-07-25 06:38:21 UTC (rev 38681)
+++ trunk/blender/release/scripts/startup/bl_operators/mesh.py	2011-07-25 06:40:16 UTC (rev 38682)
@@ -16,7 +16,7 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-# <pep8 compliant>
+# <pep8-80 compliant>
 
 import bpy
 
@@ -111,7 +111,8 @@
 
         #for i, v in enumerate(mesh.vertices):
         vmap = {}
-        for mirror_a, mirror_b in (mirror_gt, mirror_lt), (mirror_lt, mirror_gt):
+        for mirror_a, mirror_b in ((mirror_gt, mirror_lt),
+                                   (mirror_lt, mirror_gt)):
             for co, i in mirror_a.items():
                 nco = (-co[0], co[1], co[2])
                 j = mirror_b.get(nco)
@@ -120,7 +121,8 @@
 
         active_uv_layer = mesh.uv_textures.active.data
         fuvs = [(uv.uv1, uv.uv2, uv.uv3, uv.uv4) for uv in active_uv_layer]
-        fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) for uv in fuvs]
+        fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy())
+                    for uv in fuvs]
 
         # as a list
         faces = mesh.faces[:]

Modified: trunk/blender/release/scripts/startup/bl_operators/object.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/object.py	2011-07-25 06:38:21 UTC (rev 38681)
+++ trunk/blender/release/scripts/startup/bl_operators/object.py	2011-07-25 06:40:16 UTC (rev 38682)
@@ -28,9 +28,22 @@
     bl_label = "Select Pattern"
     bl_options = {'REGISTER', 'UNDO'}
 
-    pattern = StringProperty(name="Pattern", description="Name filter using '*' and '?' wildcard chars", maxlen=32, default="*")
-    case_sensitive = BoolProperty(name="Case Sensitive", description="Do a case sensitive compare", default=False)
-    extend = BoolProperty(name="Extend", description="Extend the existing selection", default=True)
+    pattern = StringProperty(
+            name="Pattern",
+            description="Name filter using '*' and '?' wildcard chars",
+            maxlen=32,
+            default="*",
+            )
+    case_sensitive = BoolProperty(
+            name="Case Sensitive",
+            description="Do a case sensitive compare",
+            default=False,
+            )
+    extend = BoolProperty(
+            name="Extend",
+            description="Extend the existing selection",
+            default=True,
+            )
 
     def execute(self, context):
 
@@ -39,7 +52,8 @@
         if self.case_sensitive:
             pattern_match = fnmatch.fnmatchcase
         else:
-            pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())
+            pattern_match = (lambda a, b:
+                                 fnmatch.fnmatchcase(a.upper(), b.upper()))
 
         obj = context.object
         if obj and obj.mode == 'POSE':
@@ -98,14 +112,19 @@
     bl_label = "Select Hierarchy"
     bl_options = {'REGISTER', 'UNDO'}
 
-    direction = EnumProperty(items=(
-                        ('PARENT', "Parent", ""),
-                        ('CHILD', "Child", "")),
-                name="Direction",
-                description="Direction to select in the hierarchy",
-                default='PARENT')
+    direction = EnumProperty(
+            items=(('PARENT', "Parent", ""),
+                   ('CHILD', "Child", ""),
+                   ),
+            name="Direction",
+            description="Direction to select in the hierarchy",
+            default='PARENT')
 
-    extend = BoolProperty(name="Extend", description="Extend the existing selection", default=False)
+    extend = BoolProperty(
+            name="Extend",
+            description="Extend the existing selection",
+            default=False,
+            )
 
     @classmethod
     def poll(cls, context):
@@ -163,7 +182,12 @@
     level = IntProperty(name="Level",
             default=1, min=-100, max=100, soft_min=-6, soft_max=6)
 
-    relative = BoolProperty(name="Relative", description="Apply the subsurf level as an offset relative to the current level", default=False)
+    relative = BoolProperty(
+            name="Relative",
+            description=("Apply the subsurf level as an offset "
+                         "relative to the current level"),
+            default=False,
+            )
 
     @classmethod
     def poll(cls, context):
@@ -215,7 +239,8 @@
                 mod = obj.modifiers.new("Subsurf", 'SUBSURF')
                 mod.levels = level
             except:
-                self.report({'WARNING'}, "Modifiers cannot be added to object: " + obj.name)
+                self.report({'WARNING'},
+                            "Modifiers cannot be added to object: " + obj.name)
 
         for obj in context.selected_editable_objects:
             set_object_subd(obj)
@@ -224,24 +249,38 @@
 
 
 class ShapeTransfer(bpy.types.Operator):
-    '''Copy another selected objects active shape to this one by applying the relative offsets'''
+    '''Copy another selected objects active shape to this one by ''' \
+    '''applying the relative offsets'''
 
     bl_idname = "object.shape_key_transfer"
     bl_label = "Transfer Shape Key"
     bl_options = {'REGISTER', 'UNDO'}
 
-    mode = EnumProperty(items=(
-                        ('OFFSET', "Offset", "Apply the relative positional offset"),
-                        ('RELATIVE_FACE', "Relative Face", "Calculate the geometricly relative position (using faces)."),
-                        ('RELATIVE_EDGE', "Relative Edge", "Calculate the geometricly relative position (using edges).")),
-                name="Transformation Mode",
-                description="Method to apply relative shape positions to the new shape",
-                default='OFFSET')
+    mode = EnumProperty(
+            items=(('OFFSET',
+                    "Offset",
+                    "Apply the relative positional offset",
+                    ),
+                   ('RELATIVE_FACE',
+                    "Relative Face",
+                    "Calculate relative position (using faces).",
+                    ),
+                   ('RELATIVE_EDGE',
+                   "Relative Edge",
+                   "Calculate relative position (using edges).",
+                   ),
+                   ),
+            name="Transformation Mode",
+            description="Relative shape positions to the new shape method",
+            default='OFFSET',
+            )
+    use_clamp = BoolProperty(
+            name="Clamp Offset",
+            description=("Clamp the transformation to the distance each "
+                         "vertex moves in the original shape."),
+            default=False,
+            )
 
-    use_clamp = BoolProperty(name="Clamp Offset",
-                description="Clamp the transformation to the distance each vertex moves in the original shape.",
-                default=False)
-
     def _main(self, ob_act, objects, mode='OFFSET', use_clamp=False):
 
         def me_nos(verts):
@@ -272,13 +311,16 @@
         orig_shape_coords = me_cos(ob_act.active_shape_key.data)
 
         orig_normals = me_nos(me.vertices)
-        # orig_coords = me_cos(me.vertices) # the actual mverts location isnt as relyable as the base shape :S
+        # the actual mverts location isnt as relyable as the base shape :S
+        # orig_coords = me_cos(me.vertices)
         orig_coords = me_cos(me.shape_keys.key_blocks[0].data)
 
         for ob_other in objects:
             me_other = ob_other.data
             if len(me_other.vertices) != len(me.vertices):
-                self.report({'WARNING'}, "Skipping '%s', vertex count differs" % ob_other.name)
+                self.report({'WARNING'},
+                            ("Skipping '%s', "
+                             "vertex count differs") % ob_other.name)
                 continue
 
             target_normals = me_nos(me_other.vertices)
@@ -395,7 +437,10 @@
 
         if 1:  # swap from/to, means we cant copy to many at once.
             if len(objects) != 1:
-                self.report({'ERROR'}, "Expected one other selected mesh object to copy from")
+                self.report({'ERROR'},
+                            ("Expected one other selected "
+                             "mesh object to copy from"))
+
                 return {'CANCELLED'}
             ob_act, objects = objects[0], [ob_act]
 
@@ -429,11 +474,14 @@
             bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
 
         if not mesh.uv_textures:
-            self.report({'WARNING'}, "Object: %s, Mesh: '%s' has no UVs\n" % (obj.name, mesh.name))
+            self.report({'WARNING'},
+                        "Object: %s, Mesh: '%s' has no UVs"
+                        % (obj.name, mesh.name))
         else:
             len_faces = len(mesh.faces)
 
-            uv_array = array.array('f', [0.0] * 8) * len_faces  # seems to be the fastest way to create an array
+            # seems to be the fastest way to create an array
+            uv_array = array.array('f', [0.0] * 8) * len_faces
             mesh.uv_textures.active.data.foreach_get("uv_raw", uv_array)
 
             objects = context.selected_editable_objects[:]
@@ -454,7 +502,8 @@
                             else:
                                 uv_other = mesh_other.uv_textures.active
                                 if not uv_other:
-                                    uv_other = mesh_other.uv_textures.new()  # should return the texture it adds
+                                    # should return the texture it adds
+                                    uv_other = mesh_other.uv_textures.new()
 
                                 # finally do the copy
                                 uv_other.data.foreach_set("uv_raw", uv_array)
@@ -482,7 +531,11 @@
 
         SCALE_FAC = 0.01
         offset = 0.5 * SCALE_FAC
-        base_tri = Vector((-offset, -offset, 0.0)), Vector((offset, -offset, 0.0)), Vector((offset, offset, 0.0)), Vector((-offset, offset, 0.0))
+        base_tri = (Vector((-offset, -offset, 0.0)),
+                    Vector((+offset, -offset, 0.0)),
+                    Vector((+offset, +offset, 0.0)),
+                    Vector((-offset, +offset, 0.0)),
+                    )
 
         def matrix_to_quat(matrix):

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list