[Bf-extensions-cvs] [87521cf] temp-sybren-blendfile: Added support for writing ints
Sybren A. Stüvel
noreply at git.blender.org
Wed Jun 22 15:20:08 CEST 2016
Commit: 87521cf8604488c0581aa23c2e3c68b6ba526d58
Author: Sybren A. Stüvel
Date: Wed Jun 22 15:19:10 2016 +0200
Branches: temp-sybren-blendfile
https://developer.blender.org/rBA87521cf8604488c0581aa23c2e3c68b6ba526d58
Added support for writing ints
===================================================================
M io_blend_utils/blend/blendfile.py
===================================================================
diff --git a/io_blend_utils/blend/blendfile.py b/io_blend_utils/blend/blendfile.py
index 516524a..651f549 100644
--- a/io_blend_utils/blend/blendfile.py
+++ b/io_blend_utils/blend/blendfile.py
@@ -800,6 +800,8 @@ class DNAStruct:
return DNA_IO.write_string(handle, value, dna_name.array_size)
else:
return DNA_IO.write_bytes(handle, value, dna_name.array_size)
+ elif dna_type.dna_type_id == b'int':
+ DNA_IO.write_int(handle, header, value)
else:
raise NotImplementedError("Setting %r is not yet supported for %r" %
(dna_type, dna_name), dna_name, dna_type)
@@ -892,6 +894,13 @@ class DNA_IO:
st = DNA_IO.SINT[fileheader.endian_index]
return st.unpack(handle.read(st.size))[0]
+ @staticmethod
+ def write_int(handle, fileheader, value):
+ assert isinstance(value, int), 'value must be int, but is %r: %r' % (type(value), value)
+ st = DNA_IO.SINT[fileheader.endian_index]
+ to_write = st.pack(value)
+ handle.write(to_write)
+
FLOAT = struct.Struct(b'<f'), struct.Struct(b'>f')
@staticmethod
More information about the Bf-extensions-cvs
mailing list