[Bf-extensions-cvs] [c9175b41] master: Cleanup: autopep8 3DS i/o

Campbell Barton noreply at git.blender.org
Sun Sep 27 04:08:27 CEST 2020


Commit: c9175b4141bbb95f9fc476ae45d6e40c626f0540
Author: Campbell Barton
Date:   Sun Sep 27 12:05:37 2020 +1000
Branches: master
https://developer.blender.org/rBACc9175b4141bbb95f9fc476ae45d6e40c626f0540

Cleanup: autopep8 3DS i/o

===================================================================

M	io_scene_3ds/__init__.py
M	io_scene_3ds/export_3ds.py
M	io_scene_3ds/import_3ds.py

===================================================================

diff --git a/io_scene_3ds/__init__.py b/io_scene_3ds/__init__.py
index af4aaa56..0137dd22 100644
--- a/io_scene_3ds/__init__.py
+++ b/io_scene_3ds/__init__.py
@@ -18,6 +18,19 @@
 
 # <pep8-80 compliant>
 
+from bpy_extras.io_utils import (
+    ImportHelper,
+    ExportHelper,
+    orientation_helper,
+    axis_conversion,
+)
+from bpy.props import (
+    BoolProperty,
+    EnumProperty,
+    FloatProperty,
+    StringProperty,
+)
+import bpy
 bl_info = {
     "name": "Autodesk 3DS format",
     "author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand",
@@ -40,21 +53,6 @@ if "bpy" in locals():
         importlib.reload(export_3ds)
 
 
-import bpy
-from bpy.props import (
-        BoolProperty,
-        EnumProperty,
-        FloatProperty,
-        StringProperty,
-        )
-from bpy_extras.io_utils import (
-        ImportHelper,
-        ExportHelper,
-        orientation_helper,
-        axis_conversion,
-        )
-
-
 @orientation_helper(axis_forward='Y', axis_up='Z')
 class Import3DS(bpy.types.Operator, ImportHelper):
     """Import from 3DS file format (.3ds)"""
@@ -66,31 +64,31 @@ class Import3DS(bpy.types.Operator, ImportHelper):
     filter_glob: StringProperty(default="*.3ds", options={'HIDDEN'})
 
     constrain_size: FloatProperty(
-            name="Size Constraint",
-            description="Scale the model by 10 until it reaches the "
-                        "size constraint (0 to disable)",
-            min=0.0, max=1000.0,
-            soft_min=0.0, soft_max=1000.0,
-            default=10.0,
-            )
+        name="Size Constraint",
+        description="Scale the model by 10 until it reaches the "
+        "size constraint (0 to disable)",
+        min=0.0, max=1000.0,
+        soft_min=0.0, soft_max=1000.0,
+        default=10.0,
+    )
     use_image_search: BoolProperty(
-            name="Image Search",
-            description="Search subdirectories for any associated images "
-                        "(Warning, may be slow)",
-            default=True,
-            )
+        name="Image Search",
+        description="Search subdirectories for any associated images "
+        "(Warning, may be slow)",
+        default=True,
+    )
     use_apply_transform: BoolProperty(
-            name="Apply Transform",
-            description="Workaround for object transformations "
-                        "importing incorrectly",
-            default=True,
-            )
+        name="Apply Transform",
+        description="Workaround for object transformations "
+        "importing incorrectly",
+        default=True,
+    )
 
     read_keyframe: bpy.props.BoolProperty(
-            name="Read Keyframe",
-            description="Read the keyframe data",
-            default=True,
-            )
+        name="Read Keyframe",
+        description="Read the keyframe data",
+        default=True,
+    )
 
     def execute(self, context):
         from . import import_3ds
@@ -116,15 +114,15 @@ class Export3DS(bpy.types.Operator, ExportHelper):
 
     filename_ext = ".3ds"
     filter_glob: StringProperty(
-            default="*.3ds",
-            options={'HIDDEN'},
-            )
+        default="*.3ds",
+        options={'HIDDEN'},
+    )
 
     use_selection: BoolProperty(
-            name="Selection Only",
-            description="Export selected objects only",
-            default=False,
-            )
+        name="Selection Only",
+        description="Export selected objects only",
+        default=False,
+    )
 
     def execute(self, context):
         from . import export_3ds
@@ -174,5 +172,6 @@ def unregister():
 # disabled scaling to size, this requires exposing bb (easy) and understanding
 # how it works (needs some time)
 
+
 if __name__ == "__main__":
     register()
diff --git a/io_scene_3ds/export_3ds.py b/io_scene_3ds/export_3ds.py
index d96d6651..de5333f9 100644
--- a/io_scene_3ds/export_3ds.py
+++ b/io_scene_3ds/export_3ds.py
@@ -37,22 +37,22 @@ from bpy_extras import node_shader_utils
 # Data Structures
 ######################################################
 
-#Some of the chunks that we will export
-#----- Primary Chunk, at the beginning of each file
+# Some of the chunks that we will export
+# ----- Primary Chunk, at the beginning of each file
 PRIMARY = 0x4D4D
 
-#------ Main Chunks
+# ------ Main Chunks
 VERSION = 0x0002  # This gives the version of the .3ds file
 KFDATA = 0xB000  # This is the header for all of the key frame info
 
-#------ sub defines of OBJECTINFO
+# ------ sub defines of OBJECTINFO
 OBJECTINFO = 0x3D3D  # Main mesh object chunk before the material and object information
 MESHVERSION = 0x3D3E  # This gives the version of the mesh
 AMBIENTLIGHT = 0x2100  # The color of the ambient light
 MATERIAL = 45055  # 0xAFFF // This stored the texture info
 OBJECT = 16384  # 0x4000 // This stores the faces, vertices, etc...
 
-#>------ sub defines of MATERIAL
+# >------ sub defines of MATERIAL
 MATNAME = 0xA000  # This holds the material name
 MATAMBIENT = 0xA010  # Ambient color of the object/material
 MATDIFFUSE = 0xA020  # This holds the color of the object/material
@@ -74,7 +74,7 @@ MAT_TEX2MAP = 0xA33A  # head for secondary texture
 MAT_SHINMAP = 0xA33C  # head for roughness map
 MAT_SELFIMAP = 0xA33D  # head for emission map
 
-#>------ sub defines of MAT_MAP
+# >------ sub defines of MAT_MAP
 MATMAPFILE = 0xA300  # This holds the file name of a texture
 MAT_MAP_TILING = 0xa351   # 2nd bit (from LSB) is mirror UV flag
 MAT_MAP_TEXBLUR = 0xA353  # Texture blurring factor
@@ -95,20 +95,20 @@ RGB2 = 0x0012  # RGB Color2
 PCT = 0x0030  # Percent chunk
 MASTERSCALE = 0x0100  # Master scale factor
 
-#>------ sub defines of OBJECT
+# >------ sub defines of OBJECT
 OBJECT_MESH = 0x4100  # This lets us know that we are reading a new object
 OBJECT_LIGHT = 0x4600  # This lets us know we are reading a light object
 OBJECT_CAMERA = 0x4700  # This lets us know we are reading a camera object
 
-#>------ Sub defines of LIGHT
+# >------ Sub defines of LIGHT
 LIGHT_MULTIPLIER = 0x465B  # The light energy factor
 LIGHT_SPOTLIGHT = 0x4610  # The target of a spotlight
 LIGHT_SPOTROLL = 0x4656  # The roll angle of the spot
 
-#>------ sub defines of CAMERA
+# >------ sub defines of CAMERA
 OBJECT_CAM_RANGES = 0x4720  # The camera range values
 
-#>------ sub defines of OBJECT_MESH
+# >------ sub defines of OBJECT_MESH
 OBJECT_VERTICES = 0x4110  # The objects vertices
 OBJECT_FACES = 0x4120  # The objects faces
 OBJECT_MATERIAL = 0x4130  # This is found if the object has a material, either texture map or color
@@ -116,13 +116,13 @@ OBJECT_UV = 0x4140  # The UV texture coordinates
 OBJECT_SMOOTH = 0x4150  # The objects smooth groups
 OBJECT_TRANS_MATRIX = 0x4160  # The Object Matrix
 
-#>------ sub defines of KFDATA
+# >------ sub defines of KFDATA
 KFDATA_KFHDR = 0xB00A
 KFDATA_KFSEG = 0xB008
 KFDATA_KFCURTIME = 0xB009
 KFDATA_OBJECT_NODE_TAG = 0xB002
 
-#>------ sub defines of OBJECT_NODE_TAG
+# >------ sub defines of OBJECT_NODE_TAG
 OBJECT_NODE_ID = 0xB030
 OBJECT_NODE_HDR = 0xB010
 OBJECT_PIVOT = 0xB013
@@ -160,6 +160,7 @@ def sane_name(name):
 def uv_key(uv):
     return round(uv[0], 6), round(uv[1], 6)
 
+
 # size defines:
 SZ_SHORT = 2
 SZ_INT = 4
@@ -236,7 +237,7 @@ class _3ds_string(object):
     def __str__(self):
         return str(self.value)
 
-    
+
 class _3ds_point_3d(object):
     """Class representing a three-dimensional point for a 3ds file."""
     __slots__ = "x", "y", "z"
@@ -253,6 +254,7 @@ class _3ds_point_3d(object):
     def __str__(self):
         return '(%f, %f, %f)' % (self.x, self.y, self.z)
 
+
 # Used for writing a track
 '''
 class _3ds_point_4d(object):
@@ -290,7 +292,7 @@ class _3ds_point_uv(object):
     def __str__(self):
         return '(%g, %g)' % self.uv
 
-    
+
 class _3ds_float_color(object):
     """Class representing a rgb float color for a 3ds file."""
     __slots__ = "r", "g", "b"
@@ -406,7 +408,7 @@ class _3ds_named_variable(object):
                   self.value)
 
 
-#the chunk class
+# the chunk class
 class _3ds_chunk(object):
     """Class representing a chunk in a 3ds file.
 
@@ -459,7 +461,7 @@ class _3ds_chunk(object):
         """Write the chunk to a file.
 
         Uses the write function of the variables and the subchunks to do the actual work."""
-        #write header
+        # write header
         self.ID.write(file)
         self.size.write(file)
         for variable in self.variables:
@@ -495,6 +497,7 @@ def get_material_image(material):
             if slot.type == 'IMAGE':
                 return slot
 
+
 def get_uv_image(ma):
     """ Get image from material wrapper."""
     if ma and ma.use_nodes:
@@ -505,6 +508,7 @@ def get_uv_image(ma):
     else:
         return get_material_image(ma)
 
+
 def make_material_subchunk(chunk_id, color):
     """Make a material subchunk.
 
@@ -516,17 +520,19 @@ def make_material_subchunk(chunk_id, color):
     # optional:
     #col2 = _3ds_chunk(RGB1)
     #col2.add_variable("color2", _3ds_rgb_color(color))
-    #mat_sub.add_subchunk(col2)
+    # mat_sub.add_subchunk(col2)
     return mat_sub
 
+
 def make_percent_subchunk(chunk_id, percent):
     """Make a percentage based subchunk."""
     pct_sub = _3ds_chunk(chunk_id)
     pcti = _3ds_chunk(PCT)
-    pcti.add_variable("percent", _3ds_ushort(int(round(percent * 100,0))))
+    pcti.add_variable("percent", _3ds_ushort(int(round(percent * 100, 0))))
     pct_sub.add_subchunk(pcti)
     return pct_sub
 
+
 def make_texture_chunk(chunk_id, images):
     """Make Material Map texture chunk."""
     # Add texture percentage value (100 = 1.0)
@@ -538,13 +544,14 @@ def make_texture_chunk(chunk_id, images):
         ma_sub_file = _3ds_chunk(MATMAPFILE)
         ma_sub_file.add_variable("image", _3ds_string(sane_name(filename)))
         ma_sub.add_subchunk(ma_sub_file)
-        
+
     for image in images:
         add_image(image)
         has_entry = True
-        
+
     return ma_sub if has_entry else None
 
+
 def make_material_texture_chunk(chunk_id, texslots, pct):
     """Make Material Map texture chunk given a seq. of `MaterialTextureSlot`'s
         Paint slots are optionally used as image source if no nodes are
@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list