Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-10-15 13:09:44 +0300
committerMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-10-15 13:09:44 +0300
commit0260327cff34787394cf9aaa3e8cc5bd35cb0a25 (patch)
tree9770b287c1f5b90afeeaecfcc0a731a9eecd8b32 /io_mesh_stl/stl_utils.py
parent376fa84e78be926b2ee7ce2b86c25d737ed6ab21 (diff)
STL: cleanup and PEP8
Unused imports, move rare imports inside functions, correct description.
Diffstat (limited to 'io_mesh_stl/stl_utils.py')
-rw-r--r--io_mesh_stl/stl_utils.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py
index 0c108e83..ee693375 100644
--- a/io_mesh_stl/stl_utils.py
+++ b/io_mesh_stl/stl_utils.py
@@ -26,14 +26,9 @@ Used as a blender script, it load all the stl files in the scene:
blender --python stl_utils.py -- file1.stl file2.stl file3.stl ...
"""
-import os
-import struct
-import contextlib
-import itertools
-from mathutils.geometry import normal
-
# TODO: endien
+
class ListDict(dict):
"""
Set struct with order.
@@ -88,6 +83,10 @@ def _is_ascii_file(data):
represents a binary file. It can be a (very *RARE* in real life, but
can easily be forged) ascii file.
"""
+
+ import os
+ import struct
+
# Skip header...
data.seek(BINARY_HEADER)
size = struct.unpack('<I', data.read(4))[0]
@@ -106,6 +105,10 @@ def _is_ascii_file(data):
def _binary_read(data):
# Skip header...
+
+ import os
+ import struct
+
data.seek(BINARY_HEADER)
size = struct.unpack('<I', data.read(4))[0]
@@ -164,6 +167,10 @@ def _ascii_read(data):
def _binary_write(filepath, faces):
+ import struct
+ import itertools
+ from mathutils.geometry import normal
+
with open(filepath, 'wb') as data:
fw = data.write
# header
@@ -191,6 +198,8 @@ def _binary_write(filepath, faces):
def _ascii_write(filepath, faces):
+ from mathutils.geometry import normal
+
with open(filepath, 'w') as data:
fw = data.write
header = _header_version()
@@ -206,10 +215,7 @@ def _ascii_write(filepath, faces):
fw('endsolid %s\n' % header)
-def write_stl(filepath="",
- faces=(),
- ascii=False,
- ):
+def write_stl(filepath="", faces=(), ascii=False):
"""
Write a stl file from faces,