From f127cafc41539ed0f604d78dfe63c300d7cfe753 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sun, 19 Sep 2010 14:26:41 +0000 Subject: [PATCH] minor syntax adjustments --- add_mesh_3d_function_surface.py | 2 +- add_mesh_gears.py | 4 ++-- add_mesh_solid.py | 12 ++++++------ io_export_directx_x.py | 4 ++-- io_export_unreal_psk_psa.py | 12 ++++++------ io_import_scene_mhx.py | 20 ++++++++++---------- io_mesh_raw/import_raw.py | 2 +- io_mesh_stl/stl_utils.py | 4 ++-- object_fracture/fracture_ops.py | 2 +- render_povray/render.py | 14 +++++++------- space_view3d_spacebar_menu.py | 2 +- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/add_mesh_3d_function_surface.py b/add_mesh_3d_function_surface.py index d82d04600..fedebd7f6 100644 --- a/add_mesh_3d_function_surface.py +++ b/add_mesh_3d_function_surface.py @@ -111,7 +111,7 @@ safe_list = ['math', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'sin', 'sinh', 'sqrt', 'tan', 'tanh'] # Use the list to filter the local namespace -safe_dict = dict([(k, globals().get(k, None)) for k in safe_list]) +safe_dict = dict((k, globals().get(k, None)) for k in safe_list) # Stores the values of a list of properties and the diff --git a/add_mesh_gears.py b/add_mesh_gears.py index 4d82f3a56..c065e27c4 100644 --- a/add_mesh_gears.py +++ b/add_mesh_gears.py @@ -350,7 +350,7 @@ def add_spoke(a, t, d, radius, De, base, s, w, l, gap=0, width=19): C = [cos(i) for i in A] S = [sin(i) for i in A] - verts.extend([(Rb * I, Rb * J, d) for (I, J) in zip(C, S)]) + verts.extend((Rb * I, Rb * J, d) for (I, J) in zip(C, S)) edgefaces2.append(len(verts) - 1) Rb = Rb - s @@ -552,7 +552,7 @@ def add_spokes(teethNum, radius, De, base, width=1, conangle=0, rack=0, radius * c, De * c, base * c, spbevel, spwidth, splength, 0, spresol) verts.extend(sv) - faces.extend([[j + fl for j in i] for i in sf]) + faces.extend([j + fl for j in i] for i in sf) fl += len(sv) d1 = fl - len(sv) diff --git a/add_mesh_solid.py b/add_mesh_solid.py index b57c01990..46ad91769 100644 --- a/add_mesh_solid.py +++ b/add_mesh_solid.py @@ -342,7 +342,7 @@ def createSolid(plato,vtrunc,etrunc,dual,snub): if vtrunc == 0: if dual: # dual is as simple as another, but mirrored platonic solid vInput,fInput = source(dualSource[plato]) - supposed_size = Asum([vInput[i] for i in fInput[0]]).length/len(fInput[0]) + supposed_size = Asum(vInput[i] for i in fInput[0]).length / len(fInput[0]) vInput = [-i*supposed_size for i in vInput] # mirror it return vInput,fInput return source(plato) @@ -352,7 +352,7 @@ def createSolid(plato,vtrunc,etrunc,dual,snub): # truncation is now equal to simple truncation of the dual of the source elif vtrunc > 0.5: vInput,fInput = source(dualSource[plato]) - supposed_size = Asum([vInput[i] for i in fInput[0]]).length/len(fInput[0]) + supposed_size = Asum(vInput[i] for i in fInput[0]).length / len(fInput[0]) # account for the source being a dual vtrunc = 1-vtrunc if vtrunc == 0: # no truncation @@ -504,7 +504,7 @@ def createSolid(plato,vtrunc,etrunc,dual,snub): # calculate supposed vertex length to ensure continuity if supposed_size: - supposed_size *= len(vert_faces[0])/Asum([verts[i] for i in vert_faces[0]]).length + supposed_size *= len(vert_faces[0])/Asum(verts[i] for i in vert_faces[0]).length verts = [-i*supposed_size for i in verts] # generate face-faces by looking up the old verts and replacing them with @@ -532,14 +532,14 @@ def createSolid(plato,vtrunc,etrunc,dual,snub): # face. do it in this order to ease the following face creation nVerts = [] for i in vert_faces: - nVerts.append(Asum([verts[j] for j in i])/len(i)) + nVerts.append(Asum(verts[j] for j in i)/len(i)) if etrunc: eStart = len(nVerts) for i in edge_faces: - nVerts.append(Asum([verts[j] for j in i])/len(i)) + nVerts.append(Asum(verts[j] for j in i)/len(i)) fStart = len(nVerts) for i in face_faces: - nVerts.append(Asum([verts[j] for j in i])/len(i)) + nVerts.append(Asum(verts[j] for j in i)/len(i)) # the special face generation for snub duals, it sucks, even i dont get it if lSnub or rSnub: for x in range(len(fInput)): diff --git a/io_export_directx_x.py b/io_export_directx_x.py index 9d13e69c6..5e82740df 100644 --- a/io_export_directx_x.py +++ b/io_export_directx_x.py @@ -101,7 +101,7 @@ def ExportDirectX(Config): if Config.ExportMode == 1: Config.ExportList = [Object for Object in Config.context.scene.objects if Object.type in ("ARMATURE", "EMPTY", "MESH") - and Object.parent == None] + and Object.parent is None] else: ExportList = [Object for Object in Config.context.selected_objects if Object.type in ("ARMATURE", "EMPTY", "MESH")] @@ -230,7 +230,7 @@ def WriteObjects(Config, ObjectList): if Config.ExportArmatures and Object.type == "ARMATURE": Armature = Object.data - ParentList = [Bone for Bone in Armature.bones if Bone.parent == None] + ParentList = [Bone for Bone in Armature.bones if Bone.parent is None] if Config.Verbose: print(" Writing Armature Bones...") WriteArmatureBones(Config, Object, ParentList) diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py index 424d1e32c..70cf85a24 100644 --- a/io_export_unreal_psk_psa.py +++ b/io_export_unreal_psk_psa.py @@ -674,7 +674,7 @@ def BoneIndexArmature(blender_armature): #print(dir(ArmatureData)) for bone in objectbone.bones: - if(bone.parent == None): + if(bone.parent is None): BoneIndex(bone) #BBCount += 1 break @@ -937,7 +937,7 @@ def parse_bone(blender_bone, psk_file, psa_file, parent_id, is_root_bone, parent #print '-------------------- Dumping Bone ---------------------- ' #If bone does not have parent that mean it the root bone - if blender_bone.parent == None: + if blender_bone.parent is None: parent_root = blender_bone @@ -1033,7 +1033,7 @@ def parse_armature(blender_armature, psk_file, psa_file): child_count = 0 for current_obj in blender_armature: current_armature = current_obj.data - bones = [x for x in current_armature.bones if not x.parent == None] + bones = [x for x in current_armature.bones if not x.parent is None] child_count += len(bones) for current_obj in blender_armature: @@ -1044,11 +1044,11 @@ def parse_armature(blender_armature, psk_file, psa_file): #we dont want children here - only the top level bones of the armature itself #we will recursively dump the child bones as we dump these bones """ - bones = [x for x in current_armature.bones if not x.parent == None] + bones = [x for x in current_armature.bones if not x.parent is None] #will ingore this part of the ocde """ for current_bone in current_armature.bones: #list the bone. #note this will list all the bones. - if(current_bone.parent == None): + if(current_bone.parent is None): parse_bone(current_bone, psk_file, psa_file, 0, 0, current_obj.matrix_local, None) break @@ -1174,7 +1174,7 @@ def parse_animation(blender_scene, blender_armatures, psa_file): #these must be ordered in the order the bones will show up in the PSA file! ordered_bones = {} - ordered_bones = sorted([(psa_file.UseBone(x.name), x) for x in pose_data.bones], key=operator.itemgetter(0)) + ordered_bones = sorted((psa_file.UseBone(x.name), x) for x in pose_data.bones, key=operator.itemgetter(0)) ############################# # ORDERED FRAME, BONE diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py index a99f17d0d..92e2e817f 100644 --- a/io_import_scene_mhx.py +++ b/io_import_scene_mhx.py @@ -473,7 +473,7 @@ def parseDefaultType(typ, args, tokens): bpyType = typ.capitalize() print(bpyType, name, data) loadedData[bpyType][name] = data - if data == None: + if data is None: return None for (key, val, sub) in tokens: @@ -514,7 +514,7 @@ def parseAction(args, tokens): act = ob.animation_data.action loadedData['Action'][name] = act - if act == None: + if act is None: print("Ignoring action %s" % name) return act act.name = name @@ -632,7 +632,7 @@ def parseKeyFramePoint(pt, args, tokens): def parseAnimationData(rna, tokens): if 0 and toggle & T_MHX: return - if rna.animation_data == None: + if rna.animation_data is None: rna.animation_data_create() adata = rna.animation_data for (key, val, sub) in tokens: @@ -742,7 +742,7 @@ def parseMaterial(args, tokens): name = args[0] #print("Parse material "+name) mat = bpy.data.materials.new(name) - if mat == None: + if mat is None: return None loadedData['Material'][name] = mat #print("Material %s %s %s" % (mat, name, loadedData['Material'][name])) @@ -899,7 +899,7 @@ def parseImage(args, tokens): for n in range(1,len(val)): filename += " " + val[n] img = loadImage(filename) - if img == None: + if img is None: return None img.name = imgName else: @@ -925,7 +925,7 @@ def parseObject(args, tokens): except: data = None - if data == None and typ != 'EMPTY': + if data is None and typ != 'EMPTY': print("Failed to find data: %s %s %s" % (name, typ, datName)) return @@ -966,7 +966,7 @@ def createObject(typ, name, data, datName): def linkObject(ob, data): #print("Data", data, ob.data) - if data and ob.data == None: + if data and ob.data is None: ob.data = data scn = bpy.context.scene scn.objects.link(ob) @@ -1267,7 +1267,7 @@ def parseVertexGroup(ob, me, args, tokens): group = ob.vertex_groups.new(grpName) group.name = grpName loadedData['VertexGroup'][grpName] = group - ob.vertex_groups.assign([int(val[0]) for (key, val, sub) in tokens if key == 'wv'], group, float(val[1]), 'REPLACE') + ob.vertex_groups.assign(int(val[0]) for (key, val, sub) in tokens if key == 'wv', group, float(val[1]), 'REPLACE') return @@ -1285,7 +1285,7 @@ def doShape(name): return (toggle & T_Face) def parseShapeKeys(ob, me, args, tokens): - if bpy.context.object == None: + if bpy.context.object is None: return for (key, val, sub) in tokens: if key == 'ShapeKey': @@ -1897,7 +1897,7 @@ def defaultKey(ext, args, tokens, var, exclude, glbals, lcals): data = None # print("Old structrna", nvar, data) - if data == None: + if data is None: try: creator = args[3] except: diff --git a/io_mesh_raw/import_raw.py b/io_mesh_raw/import_raw.py index 1cbf0a312..54adfade9 100644 --- a/io_mesh_raw/import_raw.py +++ b/io_mesh_raw/import_raw.py @@ -111,7 +111,7 @@ def addMeshObj(mesh, objName): scn.objects.link(nobj) nobj.select = True - if scn.objects.active == None or scn.objects.active.mode == 'OBJECT': + if scn.objects.active is None or scn.objects.active.mode == 'OBJECT': scn.objects.active = nobj diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py index 92723e98a..ff647b67e 100644 --- a/io_mesh_stl/stl_utils.py +++ b/io_mesh_stl/stl_utils.py @@ -195,7 +195,7 @@ def read_stl(filename): >>> pts = list(pts) >>> >>> # print the coordinate of the triangle n - >>> print([pts[i] for i in tris[n]]) + >>> print(pts[i] for i in tris[n]) ''' tris, pts = [], ListDict() @@ -209,7 +209,7 @@ def read_stl(filename): # If the point is allready in the list of points, the # index returned by pts.add() will be the one from the # first equal point inserted. - tris.append([pts.add(p) for p in pt]) + tris.append(pts.add(p) for p in pt) return tris, pts.list diff --git a/object_fracture/fracture_ops.py b/object_fracture/fracture_ops.py index b71d968a6..820b7d655 100644 --- a/object_fracture/fracture_ops.py +++ b/object_fracture/fracture_ops.py @@ -97,7 +97,7 @@ def create_cutter(context, crack_type, scale, roughness): # Adding fracture material # @todo Doesn't work at all yet. sce = bpy.context.scene - if bpy.data.materials.get('fracture')==None: + if bpy.data.materials.get('fracture') is None: bpy.ops.material.new() bpy.ops.object.material_slot_add() sce.objects.active.material_slots[0].material.name = 'fracture' diff --git a/render_povray/render.py b/render_povray/render.py index 936ddc3bd..755e12c4b 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -89,7 +89,7 @@ def write_pov(filename, scene=None, info_callback=None): file.write('\tspecular %.3g\n' % material.specular_intensity) file.write('\tambient %.3g\n' % material.ambient) - #file.write('\tambient rgb <%.3g, %.3g, %.3g>\n' % tuple([c*material.ambient for c in world.ambient_color])) # povray blends the global value + #file.write('\tambient rgb <%.3g, %.3g, %.3g>\n' % tuple(c*material.ambient for c in world.ambient_color)) # povray blends the global value # map hardness between 0.0 and 1.0 roughness = ((1.0 - ((material.specular_hardness - 1.0) / 510.0))) @@ -142,7 +142,7 @@ def write_pov(filename, scene=None, info_callback=None): file.write('\tup <0, 1, 0>\n') file.write('\tangle %f \n' % (360.0 * math.atan(16.0 / camera.data.lens) / math.pi)) - file.write('\trotate <%.6f, %.6f, %.6f>\n' % tuple([math.degrees(e) for e in matrix.rotation_part().to_euler()])) + file.write('\trotate <%.6f, %.6f, %.6f>\n' % tuple(math.degrees(e) for e in matrix.rotation_part().to_euler())) file.write('\ttranslate <%.6f, %.6f, %.6f>\n' % (matrix[3][0], matrix[3][1], matrix[3][2])) file.write('}\n') @@ -153,7 +153,7 @@ def write_pov(filename, scene=None, info_callback=None): matrix = ob.matrix_world - color = tuple([c * lamp.energy for c in lamp.color]) # Colour is modified by energy + color = tuple(c * lamp.energy for c in lamp.color) # Colour is modified by energy file.write('light_source {\n') file.write('\t< 0,0,0 >\n') @@ -304,7 +304,7 @@ def write_pov(filename, scene=None, info_callback=None): verts_normals = [tuple(v.normal) for v in me.vertices] # quads incur an extra face - quadCount = len([f for f in faces_verts if len(f) == 4]) + quadCount = sum(1 for f in faces_verts if len(f) == 4) file.write('mesh2 {\n') file.write('\tvertex_vectors {\n') @@ -455,7 +455,7 @@ def write_pov(filename, scene=None, info_callback=None): cols = col.color1, col.color2, col.color3 - if not me_materials or me_materials[material_index] == None: # No materials + if not me_materials or me_materials[material_index] is None: # No materials for i1, i2, i3 in indicies: file.write(',\n\t\t<%d,%d,%d>' % (fv[i1], fv[i2], fv[i3])) # vert count else: @@ -587,8 +587,8 @@ def write_pov(filename, scene=None, info_callback=None): exportCamera() #exportMaterials() sel = scene.objects - exportLamps([l for l in sel if l.type == 'LAMP']) - exportMeta([l for l in sel if l.type == 'META']) + exportLamps(l for l in sel if l.type == 'LAMP') + exportMeta(l for l in sel if l.type == 'META') exportMeshs(scene, sel) exportWorld(scene.world) exportGlobalSettings(scene) diff --git a/space_view3d_spacebar_menu.py b/space_view3d_spacebar_menu.py index 2f937dbd9..48f8b3418 100644 --- a/space_view3d_spacebar_menu.py +++ b/space_view3d_spacebar_menu.py @@ -1417,7 +1417,7 @@ def edgeIntersect(context, operator): line = LineLineIntersect(verts[edges[0].vertices[0]].co, verts[edges[0].vertices[1]].co, verts[edges[1].vertices[0]].co, verts[edges[1].vertices[1]].co) - if (line == None): + if (line is None): operator.report({'ERROR'}, "Selected edges are parallel.") return -- GitLab