pep8 cleanup

This commit is contained in:
Campbell Barton 2011-01-01 07:20:34 +00:00
parent 2840e7b764
commit 7f3fe8a2df
47 changed files with 288 additions and 303 deletions

@ -57,7 +57,7 @@ for line in infile.readlines():
infile.close()
# Major was changed to float, but minor is still a string
# Note: removed returning minor, this messes up with install path code in BLI module
# Note: removed returning minor, messes up install path code in BLI module
if major:
print "%.2f" % major
else:

@ -27,6 +27,7 @@ The main function to use is: update_data_paths(...)
IS_TESTING = False
class DataPathBuilder(object):
__slots__ = ("data_path", )
""" Dummy class used to parse fcurve and driver data paths.
@ -183,8 +184,6 @@ def update_data_paths(rna_update):
tar.data_path = data_path_new
print("driver (%s): %s -> %s" % (id_data_other.name, data_path, data_path_new))
for action in anim_data_actions(anim_data):
for fcu in action.fcurves:
data_path = fcu.data_path

@ -144,7 +144,6 @@ class bpy_ops_submodule_op(object):
for scene in bpy.data.scenes:
scene.update()
__doc__ = property(_get_doc)
def __init__(self, module, func):
@ -196,7 +195,8 @@ class bpy_ops_submodule_op(object):
as_string = op_as_string(idname)
op_class = getattr(bpy.types, idname)
descr = op_class.bl_rna.description
# XXX, workaround for not registering every __doc__ to save time on load.
# XXX, workaround for not registering
# every __doc__ to save time on load.
if not descr:
descr = op_class.__doc__
if not descr:

@ -31,6 +31,7 @@ import bpy as _bpy
import os as _os
import sys as _sys
def _test_import(module_name, loaded_modules):
import traceback
import time
@ -203,13 +204,11 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
# deal with addons seperately
addon_reset_all(reload_scripts)
# run the active integration preset
filepath = preset_find(_bpy.context.user_preferences.inputs.active_keyconfig, "keyconfig")
if filepath:
keyconfig_set(filepath)
if reload_scripts:
import gc
print("gc.collect() -> %d" % gc.collect())
@ -368,7 +367,6 @@ def addon_enable(module_name, default_set=True):
import bpy_types as _bpy_types
import imp
_bpy_types._register_immediate = False
def handle_error():
@ -376,7 +374,6 @@ def addon_enable(module_name, default_set=True):
traceback.print_exc()
_bpy_types._register_immediate = True
# reload if the mtime changes
mod = sys.modules.get(module_name)
if mod:
@ -595,4 +592,3 @@ def user_resource(type, path="", create=False):
target_path = ""
return target_path

@ -25,16 +25,19 @@ import bgl
import sys
def cutPoint(text, length):
"Returns position of the last space found before 'length' chars"
l = length
c = text[l]
while c != ' ':
l -= 1
if l == 0: return length # no space found
if l == 0:
return length # no space found
c = text[l]
return l
def textWrap(text, length=70):
lines = []
while len(text) > 70:
@ -44,6 +47,7 @@ def textWrap(text, length = 70):
lines.append(text)
return lines
def write_sysinfo(op):
output_filename = "system-info.txt"
warnings = 0

@ -699,5 +699,6 @@ class UpdateAnimData(bpy.types.Operator):
if __name__ == "__main__":
bpy.ops.anim.update_data_paths()
def register():
pass

@ -35,8 +35,8 @@ class bvh_node_class(object):
'children', # a list of children of this type.
'rest_head_world', # worldspace rest location for the head of this node
'rest_head_local', # localspace rest location for the head of this node
'rest_tail_world',# # worldspace rest location for the tail of this node
'rest_tail_local',# # worldspace rest location for the tail of this node
'rest_tail_world', # worldspace rest location for the tail of this node
'rest_tail_local', # worldspace rest location for the tail of this node
'channels', # list of 6 ints, -1 for an unused channel, otherwise an index for the BVH motion data lines, lock triple then rot triple
'rot_order', # a triple of indicies as to the order rotation is applied. [0,1,2] is x/y/z - [None, None, None] if no rotation.
'anim_data', # a list one tuple's one for each frame. (locx, locy, locz, rotx, roty, rotz)
@ -58,7 +58,6 @@ class bvh_node_class(object):
self.has_loc = channels[0] != -1 or channels[1] != -1 or channels[2] != -1
self.has_rot = channels[3] != -1 or channels[4] != -1 or channels[5] != -1
self.children = []
# list of 6 length tuples: (lx,ly,lz, rx,ry,rz)
@ -105,9 +104,7 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
# Split by whitespace.
file_lines = [ll for ll in [l.split() for l in file_lines] if ll]
# Create Hirachy as empties
if file_lines[0][0].lower() == 'hierarchy':
#print 'Importing the BVH Hierarchy for:', file_path
pass
@ -119,7 +116,6 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
channelIndex = -1
lineIdx = 0 # An index for the file.
while lineIdx < len(file_lines) - 1:
#...
@ -175,7 +171,6 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
my_parent = bvh_nodes_serial[-1] # account for none
# Apply the parents offset accumletivly
if my_parent is None:
rest_head_world = Vector(rest_head_local)
@ -195,7 +190,6 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0):
bvh_nodes_serial[-1].rest_tail_world = bvh_nodes_serial[-1].rest_head_world + rest_tail
bvh_nodes_serial[-1].rest_tail_local = bvh_nodes_serial[-1].rest_head_local + rest_tail
# Just so we can remove the Parents in a uniform way- End end never has kids
# so this is a placeholder
bvh_nodes_serial.append(None)

@ -36,7 +36,6 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
def rvec3d(v):
return round(v[0], 6), round(v[1], 6), round(v[2], 6)
def rvec2d(v):
return round(v[0], 6), round(v[1], 6)
@ -102,7 +101,6 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
vert_count = 0
for i, f in enumerate(mesh.faces):
smooth = f.use_smooth
if not smooth:
normal = tuple(f.normal)
@ -136,7 +134,6 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
color = col[j]
color = int(color[0] * 255.0), int(color[1] * 255.0), int(color[2] * 255.0)
key = normal_key, uvcoord_key, color
vdict_local = vdict[vidx]

@ -66,9 +66,11 @@ class Export3DS(bpy.types.Operator, ExportHelper):
def menu_func_export(self, context):
self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)")
def menu_func_import(self, context):
self.layout.operator(Import3DS.bl_idname, text="3D Studio (.3ds)")
def register():
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
@ -84,4 +86,3 @@ def unregister():
if __name__ == "__main__":
register()

@ -53,7 +53,6 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
POLYGROUPS = BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups.", default=True)
IMAGE_SEARCH = BoolProperty(name="Image Search", description="Search subdirs for any assosiated images (Warning, may be slow)", default=True)
def execute(self, context):
# print("Selected: " + context.active_object.name)
from . import import_obj
@ -99,7 +98,6 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
group_by_material = BoolProperty(name="Material Groups", description="", default=False)
keep_vertex_order = BoolProperty(name="Keep Vertex Order", description="", default=False)
def execute(self, context):
from . import export_obj
return export_obj.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
@ -117,6 +115,7 @@ def register():
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.types.INFO_MT_file_import.remove(menu_func_import)
bpy.types.INFO_MT_file_export.remove(menu_func_export)

@ -789,7 +789,6 @@ def _write(context, filepath,
EXPORT_POLYGROUPS,
EXPORT_CURVE_AS_NURBS)
scene.frame_set(orig_frame, 0.0)
# Restore old active scene.

@ -58,6 +58,7 @@ class ImportMDD(bpy.types.Operator, ImportHelper):
from . import import_mdd
return import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
class ExportMDD(bpy.types.Operator, ExportHelper):
'''Animated mesh to MDD vertex keyframe file'''
bl_idname = "export_shape.mdd"

@ -74,13 +74,11 @@ def load(operator, context, filepath, frame_start=0, frame_step=1):
verts = obj.data.shape_keys.keys[len(obj.data.shape_keys.keys) - 1].data
for v in verts: # 12 is the size of 3 floats
v.co[:] = unpack('>3f', file.read(12))
#me.update()
obj.show_only_shape_key = False
# insert keyframes
shape_keys = obj.data.shape_keys
@ -98,7 +96,6 @@ def load(operator, context, filepath, frame_start=0, frame_step=1):
obj.data.update()
for i in range(frames):
UpdateMesh(obj, i)

@ -552,7 +552,6 @@ class IsolateTypeRender(bpy.types.Operator):
return {'FINISHED'}
class ClearAllRestrictRender(bpy.types.Operator):
'''Reveal all render objects by setting the hide render flag'''
bl_idname = "object.hide_render_clear_all"

@ -156,9 +156,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
obj.location[0] = loc_x
if align_y:
# Align Mode
if relative_to == 'OPT_4': # Active relative
@ -194,11 +192,8 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
obj.location[1] = loc_y
if align_z:
# Align Mode
if relative_to == 'OPT_4': # Active relative
if align_mode == 'OPT_1':
obj_z = obj_loc[2] - negative_z - size_active_z

@ -86,6 +86,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even):
from bpy.props import *
class RandomizeLocRotSize(bpy.types.Operator):
'''Randomize objects loc/rot/scale'''
bl_idname = "object.randomize_transform"

@ -352,6 +352,7 @@ class WM_MT_operator_presets(bpy.types.Menu):
preset_operator = "script.execute_preset"
def register():
pass

@ -21,6 +21,7 @@
import bpy
from bpy.props import *
def write_svg(fw, mesh, image_width, image_height, face_iter):
# for making an XML compatible string
from xml.sax.saxutils import escape
@ -126,7 +127,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
for f in mesh_source.faces:
tot_verts += len(f.vertices)
faces_source = mesh_source.faces
# get unique UV's incase there are many overlapping which slow down filling.
@ -145,7 +145,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
mesh_new_materials = []
mesh_new_face_vertices = []
current_vert = 0
for face_data in face_hash_3:
@ -181,7 +180,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
obj_wire.material_slots[0].link = 'OBJECT'
obj_wire.material_slots[0].material = material_wire
# setup the camera
cam = bpy.data.cameras.new("uv_temp")
cam.type = 'ORTHO'
@ -204,7 +202,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
material_wire.use_shadeless = True
material_wire.diffuse_color = 0, 0, 0
# scene render settings
scene.render.use_raytrace = False
scene.render.alpha_mode = 'STRAIGHT'
@ -242,7 +239,6 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
bpy.data.materials.remove(mat_solid)
class ExportUVLayout(bpy.types.Operator):
"""Export UV layout to file"""
@ -328,7 +324,6 @@ class ExportUVLayout(bpy.types.Operator):
if is_editmode:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
mesh = obj.data
mode = self.mode

@ -102,6 +102,7 @@ class BRUSH_OT_set_active_number(bpy.types.Operator):
return {'CANCELLED'}
class WM_OT_context_set_boolean(bpy.types.Operator):
'''Set a context value.'''
bl_idname = "wm.context_set_boolean"
@ -668,7 +669,6 @@ class WM_OT_doc_edit(bpy.types.Operator):
return wm.invoke_props_dialog(self, width=600)
from bpy.props import *
@ -803,6 +803,7 @@ class WM_OT_keyconfig_activate(bpy.types.Operator):
bpy.utils.keyconfig_set(self.filepath)
return {'FINISHED'}
class WM_OT_sysinfo(bpy.types.Operator):
'''Generate System Info'''
bl_idname = "wm.sysinfo"
@ -813,6 +814,7 @@ class WM_OT_sysinfo(bpy.types.Operator):
sys_info.write_sysinfo(self)
return {'FINISHED'}
def register():
pass

@ -69,6 +69,7 @@ class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel):
layout.prop(ob, "rotation_mode")
class OBJECT_PT_delta_transform(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Delta Transform"
bl_options = {'DEFAULT_CLOSED'}

@ -551,7 +551,6 @@ class ConstraintButtonsPanel():
col.prop(con, "axis_y", text="Y")
col.prop(con, "axis_z", text="Z")
if con.pivot_type == 'CONE_TWIST':
layout.label(text="Limits:")
split = layout.split()

@ -143,7 +143,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
split.prop(tex, "type", text="")
class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}

@ -20,6 +20,7 @@
import bpy
# used for DopeSheet, NLA, and Graph Editors
def dopesheet_filter(layout, context):
dopesheet = context.space_data.dopesheet

@ -251,6 +251,7 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.menu("IMAGE_MT_uvs_showhide")
class IMAGE_MT_uvs_select_mode(bpy.types.Menu):
bl_label = "UV Select Mode"

@ -69,7 +69,6 @@ class INFO_HT_header(bpy.types.Header):
# XXX: this should be right-aligned to the RHS of the region
layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
# XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
"""
row = layout.row(align=True)
@ -220,6 +219,7 @@ class INFO_MT_curve_add(bpy.types.Menu):
layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
class INFO_MT_edit_curve_add(bpy.types.Menu):
bl_idname = "INFO_MT_edit_curve_add"
bl_label = "Add"

@ -684,7 +684,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel):
layout.template_ID(strip, "scene_camera")
sce = strip.scene
layout.label(text="Original frame range: "+ str(sce.frame_start) +" - "+ str(sce.frame_end) + " (" + str(sce.frame_end-sce.frame_start+1) + ")")
layout.label(text="Original frame range: %d-%d (%d)" % (sce.frame_start, sce.frame_end, sce.frame_end - sce.frame_start + 1))
class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel):

@ -808,6 +808,7 @@ class USERPREF_PT_input(InputKeyMapPanel):
#print("runtime", time.time() - start)
class USERPREF_MT_addons_dev_guides(bpy.types.Menu):
bl_label = "Addons develoment guides"
@ -956,8 +957,8 @@ class USERPREF_PT_addons(bpy.types.Panel):
# menu to open webpages with addons development guides
col.separator()
col.label(text = ' Online Documentation', icon = 'INFO')
col.menu('USERPREF_MT_addons_dev_guides', text='Addons Developer Guides')
col.label(text=" Online Documentation", icon='INFO')
col.menu("USERPREF_MT_addons_dev_guides", text="Addons Developer Guides")
col = split.column()

@ -128,6 +128,7 @@ class USERPREF_MT_keyconfigs(bpy.types.Menu):
bl_label = "KeyPresets"
preset_subdir = "keyconfig"
preset_operator = "wm.keyconfig_activate"
def draw(self, context):
props = self.layout.operator("wm.context_set_value", text="Blender (default)")
props.data_path = "window_manager.keyconfigs.active"

@ -647,6 +647,7 @@ class VIEW3D_MT_select_face(bpy.types.Menu): # XXX no matching enum
# ********** Object menu **********
class VIEW3D_MT_object(bpy.types.Menu):
bl_context = "objectmode"
bl_label = "Object"

@ -48,7 +48,7 @@ def file_list_py(path):
def is_pep8(path):
print(path)
f = open(path, 'r')
f = open(path, 'r', encoding="utf8")
for i in range(PEP8_SEEK_COMMENT):
line = f.readline()
if line.startswith("# <pep8"):