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:
Diffstat (limited to 'io_blend_utils/blend/blendfile.py')
-rw-r--r--io_blend_utils/blend/blendfile.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/io_blend_utils/blend/blendfile.py b/io_blend_utils/blend/blendfile.py
index c7a83c38..e471beae 100644
--- a/io_blend_utils/blend/blendfile.py
+++ b/io_blend_utils/blend/blendfile.py
@@ -30,6 +30,10 @@ log = logging.getLogger("blendfile")
FILE_BUFFER_SIZE = 1024 * 1024
+class BlendFileError(Exception):
+ """Raised when there was an error reading/parsing a blend file."""
+
+
# -----------------------------------------------------------------------------
# module global routines
#
@@ -73,9 +77,9 @@ def open_blend(filename, access="rb"):
bfile.filepath_orig = filename
return bfile
else:
- raise Exception("filetype inside gzip not a blend")
+ raise BlendFileError("filetype inside gzip not a blend")
else:
- raise Exception("filetype not a blend or a gzip blend")
+ raise BlendFileError("filetype not a blend or a gzip blend")
def pad_up_4(offset):
@@ -143,11 +147,14 @@ class BlendFile:
self.blocks.append(block)
if not self.structs:
- raise Exception("No DNA1 block in file, this is not a valid .blend file!")
+ raise BlendFileError("No DNA1 block in file, this is not a valid .blend file!")
# cache (could lazy init, incase we never use?)
self.block_from_offset = {block.addr_old: block for block in self.blocks if block.code != b'ENDB'}
+ def __repr__(self):
+ return '<%s %r>' % (self.__class__.__qualname__, self.handle)
+
def __enter__(self):
return self