Pārlūkot izejas kodu

pep8 and pylint compliance

Jason0214 7 gadi atpakaļ
vecāks
revīzija
0fc9d643d5

+ 2 - 2
io_scene_godot/converters/material.py

@@ -71,9 +71,9 @@ def _find_material_in_subtree(folder, material):
     candidates = []
     candidates = []
 
 
     material_file_name = material.name + '.tres'
     material_file_name = material.name + '.tres'
-    for folder, _subdirs, files in os.walk(folder):
+    for dir_path, _subdirs, files in os.walk(folder):
         if material_file_name in files:
         if material_file_name in files:
-            candidates.append(os.path.join(folder, material_file_name))
+            candidates.append(os.path.join(dir_path, material_file_name))
 
 
     # Checks it is a material and finds out what type
     # Checks it is a material and finds out what type
     valid_candidates = []
     valid_candidates = []

+ 1 - 1
io_scene_godot/converters/mesh.py

@@ -91,7 +91,7 @@ def make_arrays(escn_file, export_settings, node, armature):
     if uv_layer_count > 2:
     if uv_layer_count > 2:
         uv_layer_count = 2
         uv_layer_count = 2
 
 
-    if len(mesh.uv_textures):
+    if mesh.uv_textures:
         has_tangents = True
         has_tangents = True
         mesh.calc_tangents()
         mesh.calc_tangents()
     else:
     else:

+ 8 - 5
io_scene_godot/converters/physics.py

@@ -4,7 +4,6 @@ object is exported. In blender, the object owns the physics. In Godot, the
 physics owns the object.
 physics owns the object.
 """
 """
 
 
-import os
 import math
 import math
 import logging
 import logging
 import bpy
 import bpy
@@ -69,7 +68,8 @@ def export_collision_shape(escn_file, export_settings, node, parent_gd_node,
         col_node['transform'] = mathutils.Matrix.Identity(4) * AXIS_CORRECT
         col_node['transform'] = mathutils.Matrix.Identity(4) * AXIS_CORRECT
     else:
     else:
         parent_to_world = parent_override.matrix_world.inverted()
         parent_to_world = parent_override.matrix_world.inverted()
-        col_node['transform'] = parent_to_world * node.matrix_world * AXIS_CORRECT
+        col_node['transform'] = (
+            parent_to_world * node.matrix_world * AXIS_CORRECT)
 
 
     rbd = node.rigid_body
     rbd = node.rigid_body
 
 
@@ -112,6 +112,7 @@ def export_collision_shape(escn_file, export_settings, node, parent_gd_node,
 
 
 
 
 def generate_convex_mesh_array(escn_file, export_settings, node):
 def generate_convex_mesh_array(escn_file, export_settings, node):
+    """Generates godots ConvexPolygonShape from an object"""
     mesh = node.data
     mesh = node.data
     key = (mesh, "ConvexCollisionMesh")
     key = (mesh, "ConvexCollisionMesh")
     resource_id = escn_file.get_internal_resource(key)
     resource_id = escn_file.get_internal_resource(key)
@@ -128,7 +129,7 @@ def generate_convex_mesh_array(escn_file, export_settings, node):
     triangulated_mesh = bmesh.new()
     triangulated_mesh = bmesh.new()
     triangulated_mesh.from_mesh(mesh)
     triangulated_mesh.from_mesh(mesh)
     # For some reason, generateing the convex hull here causes Godot to crash
     # For some reason, generateing the convex hull here causes Godot to crash
-    #bmesh.ops.convex_hull(triangulated_mesh, input=triangulated_mesh.verts)
+    # bmesh.ops.convex_hull(triangulated_mesh, input=triangulated_mesh.verts)
     bmesh.ops.triangulate(triangulated_mesh, faces=triangulated_mesh.faces)
     bmesh.ops.triangulate(triangulated_mesh, faces=triangulated_mesh.faces)
     triangulated_mesh.to_mesh(mesh)
     triangulated_mesh.to_mesh(mesh)
     triangulated_mesh.free()
     triangulated_mesh.free()
@@ -178,7 +179,8 @@ def generate_triangle_mesh_array(escn_file, export_settings, node):
     return escn_file.add_internal_resource(col_shape, key)
     return escn_file.add_internal_resource(col_shape, key)
 
 
 
 
-def export_physics_controller(escn_file, export_settings, node, parent_gd_node):
+def export_physics_controller(escn_file, export_settings, node,
+                              parent_gd_node):
     """Exports the physics body "type" as a separate node. In blender, the
     """Exports the physics body "type" as a separate node. In blender, the
     physics body type and the collision shape are one object, in godot they
     physics body type and the collision shape are one object, in godot they
     are two. This is the physics body type"""
     are two. This is the physics body type"""
@@ -218,7 +220,8 @@ def export_physics_controller(escn_file, export_settings, node, parent_gd_node):
     return phys_obj
     return phys_obj
 
 
 
 
-def export_physics_properties(escn_file, export_settings, node, parent_gd_node):
+def export_physics_properties(escn_file, export_settings, node,
+                              parent_gd_node):
     """Creates the necessary nodes for the physics"""
     """Creates the necessary nodes for the physics"""
     parent_rbd = get_physics_root(node)
     parent_rbd = get_physics_root(node)
 
 

+ 2 - 1
io_scene_godot/converters/simple_nodes.py

@@ -81,7 +81,8 @@ def export_lamp_node(escn_file, export_settings, node, parent_gd_node):
             )
             )
 
 
     elif light.type == "SUN":
     elif light.type == "SUN":
-        light_node = NodeTemplate(node.name, "DirectionalLight", parent_gd_node)
+        light_node = NodeTemplate(node.name, "DirectionalLight",
+                                  parent_gd_node)
         light_node['shadow_enabled'] = light.shadow_method != "NOSHADOW"
         light_node['shadow_enabled'] = light.shadow_method != "NOSHADOW"
     else:
     else:
         light_node = None
         light_node = None

+ 7 - 2
io_scene_godot/export_godot.py

@@ -73,7 +73,8 @@ class GodotExporter:
             exporter = converters.BLENDER_TYPE_TO_EXPORTER["EMPTY"]
             exporter = converters.BLENDER_TYPE_TO_EXPORTER["EMPTY"]
 
 
         # Perform the export
         # Perform the export
-        parent_gd_node = exporter(self.escn_file, self.config, node, parent_gd_node)
+        parent_gd_node = exporter(self.escn_file, self.config, node,
+                                  parent_gd_node)
 
 
         for child in node.children:
         for child in node.children:
             self.export_node(child, parent_gd_node)
             self.export_node(child, parent_gd_node)
@@ -102,7 +103,11 @@ class GodotExporter:
     def export_scene(self):
     def export_scene(self):
         """Decide what objects to export, and export them!"""
         """Decide what objects to export, and export them!"""
         # Scene root
         # Scene root
-        root_gd_node = structures.NodeTemplate(self.scene.name, "Spatial", None)
+        root_gd_node = structures.NodeTemplate(
+            self.scene.name,
+            "Spatial",
+            None
+        )
         self.escn_file.add_node(root_gd_node)
         self.escn_file.add_node(root_gd_node)
         logging.info("Exporting scene: %s", self.scene.name)
         logging.info("Exporting scene: %s", self.scene.name)
 
 

+ 1 - 1
io_scene_godot/structures.py

@@ -175,7 +175,6 @@ class NodeTemplate(FileEntry):
                 ))
                 ))
             )
             )
 
 
-
     def get_name(self):
     def get_name(self):
         """Get the name of the node in Godot scene"""
         """Get the name of the node in Godot scene"""
         return self.heading['name']
         return self.heading['name']
@@ -196,6 +195,7 @@ class NodeTemplate(FileEntry):
         """Get the node type in Godot scene"""
         """Get the node type in Godot scene"""
         return self.heading["type"]
         return self.heading["type"]
 
 
+
 class ExternalResource(FileEntry):
 class ExternalResource(FileEntry):
     """External Resouces are references to external files. In the case of
     """External Resouces are references to external files. In the case of
     an escn export, this is mostly used for images, sounds and so on"""
     an escn export, this is mostly used for images, sounds and so on"""