diff options
author | Alexander N <alpha-beta-release@gmx.net> | 2013-04-12 18:07:09 +0400 |
---|---|---|
committer | Alexander N <alpha-beta-release@gmx.net> | 2013-04-12 18:07:09 +0400 |
commit | 19d63c89c7d9f6e2ad9da9258d651a8826f37975 (patch) | |
tree | 27604471c7b635c06bd1c010b8eede76dc0e98da /io_scene_ms3d/ms3d_import.py | |
parent | 7d6131d4e390d0981208b78f08afa67189e5ce08 (diff) |
raise HeaderError if, file header is invalid.
Diffstat (limited to 'io_scene_ms3d/ms3d_import.py')
-rw-r--r-- | io_scene_ms3d/ms3d_import.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/io_scene_ms3d/ms3d_import.py b/io_scene_ms3d/ms3d_import.py index c9e87c23..e824aba1 100644 --- a/io_scene_ms3d/ms3d_import.py +++ b/io_scene_ms3d/ms3d_import.py @@ -56,6 +56,7 @@ from io_scene_ms3d.ms3d_spec import ( Ms3dModel, Ms3dVertexEx2, Ms3dVertexEx3, + Ms3dHeader, ) from io_scene_ms3d.ms3d_utils import ( select_all, @@ -160,16 +161,27 @@ class Ms3dImporter(): print(statistics) print("##########################################################") + except Ms3dHeader.HeaderError: + msg = "read - invalid file format." + if self.options_verbose in Ms3dUi.VERBOSE_NORMAL: + print(msg) + if self.report: + self.report({'WARNING', 'ERROR', }, msg) + + return False + except Exception: type, value, traceback = exc_info() if self.options_verbose in Ms3dUi.VERBOSE_NORMAL: print("read - exception in try block\n type: '{0}'\n" " value: '{1}'".format(type, value, traceback)) + if self.report: + self.report({'WARNING', 'ERROR', }, "read - exception.") if t2 is None: t2 = time() - raise + return False else: pass @@ -180,7 +192,7 @@ class Ms3dImporter(): print(ms3d_str['SUMMARY_IMPORT'].format( (t3 - t1), (t2 - t1), (t3 - t2))) - return {"FINISHED"} + return True ########################################################################### @@ -495,35 +507,39 @@ class Ms3dImporter(): bmv_new[layer_extra] = bmv[layer_extra] vert_index = length_verts length_verts += 1 - self.report({'WARNING', 'INFO'}, - ms3d_str['WARNING_IMPORT_EXTRA_VERTEX_NORMAL'].format( - bmv.normal, blender_normal)) + if self.report and self.options_verbose in Ms3dUi.VERBOSE_NORMAL: + self.report({'WARNING', 'INFO'}, + ms3d_str['WARNING_IMPORT_EXTRA_VERTEX_NORMAL'].format( + bmv.normal, blender_normal)) bmv = bmv_new if [[x] for x in bmv_list if x == bmv]: - self.report( - {'WARNING', 'INFO'}, - ms3d_str['WARNING_IMPORT_SKIP_VERTEX_DOUBLE'].format( - ms3d_triangle_index)) + if self.report and self.options_verbose in Ms3dUi.VERBOSE_NORMAL: + self.report( + {'WARNING', 'INFO'}, + ms3d_str['WARNING_IMPORT_SKIP_VERTEX_DOUBLE'].format( + ms3d_triangle_index)) continue bmv_list.append(bmv) bmf_normal += bmv.normal if len(bmv_list) < 3: - self.report( - {'WARNING', 'INFO'}, - ms3d_str['WARNING_IMPORT_SKIP_LESS_VERTICES'].format( - ms3d_triangle_index)) + if self.report and self.options_verbose in Ms3dUi.VERBOSE_NORMAL: + self.report( + {'WARNING', 'INFO'}, + ms3d_str['WARNING_IMPORT_SKIP_LESS_VERTICES'].format( + ms3d_triangle_index)) continue bmf_normal.normalize() bmf = bm.faces.get(bmv_list) if bmf is not None: - self.report( - {'WARNING', 'INFO'}, - ms3d_str['WARNING_IMPORT_SKIP_FACE_DOUBLE'].format( - ms3d_triangle_index)) + if self.report and self.options_verbose in Ms3dUi.VERBOSE_NORMAL: + self.report( + {'WARNING', 'INFO'}, + ms3d_str['WARNING_IMPORT_SKIP_FACE_DOUBLE'].format( + ms3d_triangle_index)) continue bmf = bm.faces.new(bmv_list) |