String fix and a bunch of PEP8 issues I had collected in the meanwhile.
authorGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>
Fri, 4 Dec 2009 17:54:48 +0000 (17:54 +0000)
committerGuillermo S. Romero <gsr.b3d@infernal-iceberg.com>
Fri, 4 Dec 2009 17:54:48 +0000 (17:54 +0000)
14 files changed:
release/scripts/modules/retopo.py
release/scripts/modules/rna_prop_ui.py
release/scripts/op/console_python.py
release/scripts/op/console_shell.py
release/scripts/ui/properties_physics_cloth.py
release/scripts/ui/space_console.py
release/scripts/ui/space_image.py
release/scripts/ui/space_info.py
release/scripts/ui/space_node.py
release/scripts/ui/space_outliner.py
release/scripts/ui/space_sequencer.py
release/scripts/ui/space_text.py
release/scripts/ui/space_userpref.py
release/scripts/ui/space_view3d.py

index 081ac1b0168d0059d9ee09b5738f7ff30425f77d..0bf822c9ed419e3bcc72cb894b46daba44bc640e 100644 (file)
@@ -22,19 +22,20 @@ import bpy
 
 EPS_SPLINE_DIV = 15.0 # remove doubles is ~15th the length of the spline
 
+
 def get_hub(co, _hubs, EPS_SPLINE):
-    
+
     if 1:
         for hub in _hubs.values():
             if (hub.co - co).length < EPS_SPLINE:
                 return hub
-        
+
         key = co.toTuple(3)
         hub = _hubs[key] = Hub(co, key, len(_hubs))
         return hub
     else:
         pass
-        
+
         '''
         key = co.toTuple(3)
         try:
@@ -43,10 +44,11 @@ def get_hub(co, _hubs, EPS_SPLINE):
             hub = _hubs[key] = Hub(co, key, len(_hubs))
             return hub
         '''
-        
+
 
 class Hub(object):
     __slots__ = "co", "key", "index", "links"
+
     def __init__(self, co, key, index):
         self.co = co.copy()
         self.key = key
@@ -55,10 +57,10 @@ class Hub(object):
 
     def get_weight(self):
         f = 0.0
-        
+
         for hub_other in self.links:
             f += (self.co - hub_other.co).length
-    
+
     def replace(self, other):
         for hub in self.links:
             try:
@@ -67,8 +69,7 @@ class Hub(object):
                 pass
             if other not in hub.links:
                 hub.links.append(other)
-            
-    
+
     def dist(self, other):
         return (self.co - other.co).length
 
@@ -80,9 +81,8 @@ class Hub(object):
                 if l_b is not self and l_b in self.links:
                     # will give duplicates
                     faces.append((self.index, l_a.index, l_b.index))
-        
-        # now quads, check which links share 2 different verts
-        # directly
+
+        # now quads, check which links share 2 different verts directly
         def validate_quad(face):
             if len(set(face)) != len(face):
                 return False
@@ -90,41 +90,41 @@ class Hub(object):
                 return False
             if hub_ls[face[2]] in hub_ls[face[0]].links:
                 return False
-                
+
             if hub_ls[face[1]] in hub_ls[face[3]].links:
                 return False
             if hub_ls[face[3]] in hub_ls[face[1]].links:
                 return False
-            
+
             return True
 
         for i, l_a in enumerate(self.links):
             links_a = set([l.index for l in l_a.links])
             for j in range(i):
                 l_b = self.links[j]
-                
+
                 links_b = set([l.index for l in l_b.links])
-                
+
                 isect = links_a.intersection(links_b)
                 if len(isect) == 2:
                     isect = list(isect)
-                    
+
                     # check there are no diagonal lines
                     face = (isect[0], l_a.index, isect[1], l_b.index)
                     if validate_quad(face):
-                    
+
                         faces.append(face)
-        
+
         return faces
-    
 
 
 class Spline:
     __slots__ = "points", "hubs", "length"
+
     def __init__(self, points):
         self.points = points
         self.hubs = []
-        
+
         # calc length
         f = 0.0
         co_prev = self.points[0]
@@ -136,46 +136,49 @@ class Spline:
     def link(self):
         if len(self.hubs) < 2:
             return
-        
+
         edges = list(set([i for i, hub in self.hubs]))
         edges.sort()
 
         edges_order = {}
         for i in edges:
             edges_order[i] = []
-        
-        
+
+
         # self.hubs.sort()
         for i, hub in self.hubs:
             edges_order[i].append(hub)
-        
+
         hubs_order = []
         for i in edges:
             ls = edges_order[i]
             edge_start = self.points[i]
             ls.sort(key=lambda hub: (hub.co - edge_start).length)
             hubs_order.extend(ls)
-        
+
         # Now we have the order, connect the hubs
         hub_prev = hubs_order[0]
-        
+
         for hub in hubs_order[1:]:
             hub.links.append(hub_prev)
             hub_prev.links.append(hub)
             hub_prev = hub
 
+
 def get_points(stroke):
     return [point.co.copy() for point in stroke.points]
 
+
 def get_splines(gp):
     for l in gp.layers:
         if l.active: # XXX - should be layers.active
             break
-    
+
     frame = l.active_frame
-    
+
     return [Spline(get_points(stroke)) for stroke in frame.strokes]
 
+
 def xsect_spline(sp_a, sp_b, _hubs):
     from Mathutils import LineIntersect
     from Mathutils import MidpointVecs
@@ -191,7 +194,7 @@ def xsect_spline(sp_a, sp_b, _hubs):
             # print(pt_a, pt_a_prev, pt_b, pt_b_prev)
             xsect = LineIntersect(pt_a, pt_a_prev, pt_b, pt_b_prev)
             if xsect is not None:
-                if (xsect[0]-xsect[1]).length <= EPS_SPLINE:
+                if (xsect[0] - xsect[1]).length <= EPS_SPLINE:
                     f = ClosestPointOnLine(xsect[1], pt_a, pt_a_prev)[1]
                     # if f >= 0.0-EPS_SPLINE and f <= 1.0+EPS_SPLINE: # for some reason doesnt work so well, same below
                     if f >= 0.0 and f <= 1.0:
@@ -206,90 +209,90 @@ def xsect_spline(sp_a, sp_b, _hubs):
                             sp_b.hubs.append((b, hub))
 
             pt_b_prev = pt_b
-            
+
         pt_a_prev = pt_a
 
 
 def calculate(gp):
     splines = get_splines(gp)
     _hubs = {}
-    
+
     for i, sp in enumerate(splines):
         for j, sp_other in enumerate(splines):
-            if j<=i:
+            if j <= i:
                 continue
 
             xsect_spline(sp, sp_other, _hubs)
-            
+
     for sp in splines:
         sp.link()
-    
+
     # remove these
     hubs_ls = [hub for hub in _hubs.values() if hub.index != -1]
-        
+
     _hubs.clear()
     _hubs = None
-    
+
     for i, hub in enumerate(hubs_ls):
         hub.index = i
-    
+
     # Now we have connected hubs, write all edges!
     def order(i1, i2):
         if i1 > i2:
             return i2, i1
         return i1, i2
-    
+
     edges = {}
-    
+
     for hub in hubs_ls:
         i1 = hub.index
-        for hub_other in hub.links: 
+        for hub_other in hub.links:
             i2 = hub_other.index
             edges[order(i1, i2)] = None
-    
+
     verts = []
     edges = edges.keys()
     faces = []
-    
+
     for hub in hubs_ls:
         verts.append(hub.co)
         faces.extend(hub.calc_faces(hubs_ls))
-    
+
     # remove double faces
     faces = dict([(tuple(sorted(f)), f) for f in faces]).values()
-        
+
     mesh = bpy.data.add_mesh("Retopo")
     mesh.from_pydata(verts, [], faces)
-    
+
     scene = bpy.context.scene
     mesh.update()
     obj_new = bpy.data.add_object('MESH', "Torus")
     obj_new.data = mesh
     scene.objects.link(obj_new)
-    
+
     return obj_new
-    
-    
+
+
 def main():
     scene = bpy.context.scene
     obj = bpy.context.object
-    
+
     gp = None
-    
+
     if obj:
         gp = obj.grease_pencil
-    
+
     if not gp:
         gp = scene.grease_pencil
 
     if not gp:
         raise Exception("no active grease pencil")
-    
+
     obj_new = calculate(gp)
-    
+
     scene.objects.active = obj_new
     obj_new.selected = True
-    
+
     # nasty, recalc normals
     bpy.ops.object.mode_set(mode='EDIT', toggle=False)
     bpy.ops.mesh.normals_make_consistent(inside=False)
index d19449f9404e1d1f2e4a7c5badbc2c5e0f19a13a..1e1747220e16df4834de05dbc5a1a75a3371cf45 100644 (file)
@@ -20,6 +20,7 @@
 
 import bpy
 
+
 def rna_idprop_ui_get(item, create=True):
     try:
         return item['_RNA_UI']
@@ -57,7 +58,7 @@ def rna_idprop_ui_prop_clear(item, prop):
         pass
 
 
-def draw(layout, context, context_member, use_edit = True):
+def draw(layout, context, context_member, use_edit=True):
 
     def assign_props(prop, val, key):
         prop.path = context_member
@@ -69,7 +70,7 @@ def draw(layout, context, context_member, use_edit = True):
             pass
 
     rna_item = eval("context." + context_member)
-    
+
     # poll should really get this...
     if not rna_item:
         return
@@ -138,6 +139,7 @@ rna_property = StringProperty(name="Property Name",
 rna_min = FloatProperty(name="Min", default=0.0, precision=3)
 rna_max = FloatProperty(name="Max", default=1.0, precision=3)
 
+
 class WM_OT_properties_edit(bpy.types.Operator):
     '''Internal use (edit a property path)'''
     bl_idname = "wm.properties_edit"
@@ -206,15 +208,15 @@ class WM_OT_properties_edit(bpy.types.Operator):
         prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
         if prop_ui:
             self.properties.min = prop_ui.get("min", -1000000000)
-            self.properties.max = prop_ui.get("max",  1000000000)
-            self.properties.description = prop_ui.get("description",  "")
+            self.properties.max = prop_ui.get("max", 1000000000)
+            self.properties.description = prop_ui.get("description", "")
 
         if 0:
-            _message= "PyConsole, press Ctrl+D to unlock the BGE"
+            _message = "PyConsole, press Ctrl+D to unlock the BGE"
             import sys
 
             # evaluate commands in current namespace
-            frame= sys._getframe()
+            frame = sys._getframe()
             namespace = frame.f_globals.copy()
             namespace.update(frame.f_locals)
 
@@ -252,7 +254,7 @@ class WM_OT_properties_add(bpy.types.Operator):
             i = 1
             while prop_new in names:
                 prop_new = prop + str(i)
-                i+=1
+                i += 1
 
             return prop_new
 
@@ -261,6 +263,7 @@ class WM_OT_properties_add(bpy.types.Operator):
         item[property] = 1.0
         return ('FINISHED',)
 
+
 class WM_OT_properties_remove(bpy.types.Operator):
     '''Internal use (edit a property path)'''
     bl_idname = "wm.properties_remove"
@@ -273,4 +276,3 @@ class WM_OT_properties_remove(bpy.types.Operator):
         item = eval("context.%s" % self.properties.path)
         del item[self.properties.property]
         return ('FINISHED',)
-
index 532602655facb36e4c4b174a15b9f746d93fb6f6..7f1d35ede209949ec5eadf1c3efe6f7f643836b0 100644 (file)
@@ -22,11 +22,13 @@ import bpy
 
 language_id = 'python'
 
+
 def add_scrollback(text, text_type):
     for l in text.split('\n'):
         bpy.ops.console.scrollback_append(text=l.replace('\t', '    '),
             type=text_type)
 
+
 def get_console(console_id):
     '''
     helper function for console operators
@@ -70,6 +72,7 @@ def get_console(console_id):
 PROMPT = '>>> '
 PROMPT_MULTI = '... '
 
+
 def execute(context):
     sc = context.space_data
 
index 7262a434a5108f74de9b8831912eee0d94fa34f8..7dec9477f51b1a14a9c7dc7c1c709169e39bd3cc 100644 (file)
@@ -25,19 +25,21 @@ import bpy
 
 language_id = 'shell'
 
+
 def add_scrollback(text, text_type):
     for l in text.split('\n'):
         bpy.ops.console.scrollback_append(text=l.replace('\t', '    '),
             type=text_type)
 
+
 def shell_run(text):
     import subprocess
-    val, output= subprocess.getstatusoutput(text)
+    val, output = subprocess.getstatusoutput(text)
 
     if not val:
-        style= 'OUTPUT'
+        style = 'OUTPUT'
     else:
-        style= 'ERROR'
+        style = 'ERROR'
 
     add_scrollback(output, style)
 
@@ -60,7 +62,7 @@ def execute(context):
     bpy.ops.console.history_append(text="", current_character=0,
         remove_duplicates=True)
 
-    sc.prompt = os.getcwd()+PROMPT
+    sc.prompt = os.getcwd() + PROMPT
     return ('FINISHED',)
 
 
@@ -74,7 +76,6 @@ def banner(context):
     sc = context.space_data
 
     shell_run("bash --version")
-    sc.prompt = os.getcwd()+PROMPT
+    sc.prompt = os.getcwd() + PROMPT
 
     return ('FINISHED',)
-
index 7123e52fb8d93641f29483a00ed422b1b2c024d8..305244bf9185325249eb7a511e612e6f3eb91074 100644 (file)
@@ -84,7 +84,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
             cloth = md.settings
 
             split = layout.split()
-            
+
             split.active = cloth_panel_enabled(md)
 
             col = split.column()
index a59c39d52ec7fcf49ebfdbf2a2dae3575e8e53a3..5e086435ddde15f4503e521cc85a7a0f9be04fab 100644 (file)
@@ -69,12 +69,13 @@ class CONSOLE_MT_console(bpy.types.Menu):
         layout.operator("console.copy")
         layout.operator("console.paste")
         layout.menu("CONSOLE_MT_language")
-        
+
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
+
 class CONSOLE_MT_report(bpy.types.Menu):
     bl_label = "Report"
 
index 9c5c92dbaef3912b55716a4d791a0be97ad52dc4..5714a3d2548f2d40cb81a30b816c453f10b33767 100644 (file)
@@ -61,9 +61,9 @@ class IMAGE_MT_view(bpy.types.Menu):
             layout.operator("image.view_selected")
 
         layout.operator("image.view_all")
-       
+
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
index a9365ad2ecb872bd726e4ede0fb87ef6973d13b5..ad94bdd0beba4485740ece040102ae21ed143500 100644 (file)
@@ -83,18 +83,18 @@ class INFO_MT_file(bpy.types.Menu):
         layout.operator("wm.save_mainfile", text="Save", icon='ICON_FILE_TICK')
         layout.operator_context = 'INVOKE_AREA'
         layout.operator("wm.save_as_mainfile", text="Save As...")
-        
+
         layout.separator()
-        
+
         layout.operator("screen.userpref_show", text="User Preferences...", icon='ICON_PREFERENCES')
         layout.operator("wm.read_homefile", text="Load Factory Settings").factory = True
 
         layout.separator()
-        
+
         layout.operator_context = 'INVOKE_AREA'
         layout.operator("wm.link_append", text="Link")
         layout.operator("wm.link_append", text="Append").link = False
-        
+
         layout.separator()
 
         layout.menu("INFO_MT_file_import")
index ed212053eccbbe9962295a06c94574f69ff511ae..c05ab767f852b8e8e822e53f5af77d7b4b2fc305 100644 (file)
@@ -82,9 +82,9 @@ class NODE_MT_view(bpy.types.Menu):
         layout.separator()
 
         layout.operator("node.view_all")
-        
+
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
index f6ad0b68f8003ec72a2bcd82b9fafd56a43bc5d8..cc2c6a633ae626e8b11ad8ba0d8099d936143d3e 100644 (file)
@@ -76,9 +76,9 @@ class OUTLINER_MT_view(bpy.types.Menu):
 
         col.operator("outliner.show_one_level")
         col.operator("outliner.show_hierarchy")
-        
+
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
index 00361ca86aa5570308696f04a079e0080feabec6..b2bd017262fd0b7be4a8cb348cfa2d0484973476 100644 (file)
@@ -109,10 +109,11 @@ class SEQUENCER_MT_view(bpy.types.Menu):
             layout.prop(st, "separate_color_preview")
 
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
+
 class SEQUENCER_MT_select(bpy.types.Menu):
     bl_label = "Select"
 
@@ -336,8 +337,8 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
         if not strip:
             return False
 
-        return strip.type in ('ADD','SUBTRACT','ALPHA_OVER','ALPHA_UNDER',
-                              'GAMMA_CROSS','MULTIPLY','OVER_DROP',
+        return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
+                              'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
                               'PLUGIN',
                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
 
index fad8ab3b6100b4b13d51e144e4d2b39cfcf64cad..95175e9ce410ceb1cf7df3e365c493b7b9ea8e83 100644 (file)
@@ -123,7 +123,6 @@ class TEXT_PT_find(bpy.types.Panel):
         row.prop(st, "find_all", text="All")
 
 
-
 class TEXT_MT_text(bpy.types.Menu):
     bl_label = "Text"
 
@@ -160,9 +159,9 @@ class TEXT_MT_text(bpy.types.Menu):
         layout.operator("text.properties", icon='ICON_MENU_PANEL')
 
         layout.menu("TEXT_MT_templates")
-        
+
         layout.separator()
-       
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.screen_full_area")
 
index 69f75b5448288883b6e1fcf502773fbef82eb93c..5a8dbf9ee80cd7fc85f9e9bd9985f883edf8e1f6 100644 (file)
@@ -1415,9 +1415,9 @@ class WM_OT_keymap_edit(bpy.types.Operator):
 
 
 class WM_OT_keymap_restore(bpy.types.Operator):
-    "Restore key map"
+    "Restore key map(s)."
     bl_idname = "wm.keymap_restore"
-    bl_label = "Restore Key Map"
+    bl_label = "Restore Key Map(s)"
 
     all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
 
index 97ae62e2d3ef016694ab7295bd8c5a55d76f230a..af722c7f4d7e3ae09d63e8283ac590399fc304bf 100644 (file)
@@ -32,15 +32,15 @@ class VIEW3D_HT_header(bpy.types.Header):
         edit_object = context.edit_object
         obj = context.active_object
         toolsettings = context.scene.tool_settings
-        
+
         row = layout.row()
         row.template_header()
-        
+
         sub = row.row(align=True)
-        
+
         # Menus
         if context.area.show_menus:
-            
+
             sub.menu("VIEW3D_MT_view")
 
             # Select Menu
@@ -269,19 +269,15 @@ class VIEW3D_MT_view(bpy.types.Menu):
         layout.operator("view3d.view_all")
 
         layout.separator()
-        
+
         layout.operator("screen.animation_play", text="Playback Animation")
-        
+
         layout.separator()
-        
+
         layout.operator("screen.area_dupli")
         layout.operator("screen.region_quadview")
         layout.operator("screen.screen_full_area")
 
-        
-
-        
-
 
 class VIEW3D_MT_view_navigation(bpy.types.Menu):
     bl_label = "Navigation"
@@ -413,7 +409,7 @@ class VIEW3D_MT_select_pose(bpy.types.Menu):
         props = layout.operator("pose.select_hierarchy", text="Extend Child")
         props.extend = True
         props.direction = 'CHILD'
-        
+
         layout.operator("object.select_pattern", text="Select Pattern...")
 
 
@@ -605,7 +601,7 @@ class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
         props = layout.operator("armature.select_hierarchy", text="Extend Child")
         props.extend = True
         props.direction = 'CHILD'
-        
+
         layout.operator("object.select_pattern", text="Select Pattern...")