From 8ef3a7e47c83bba1a6d89fce757d577e55335074 Mon Sep 17 00:00:00 2001 From: SE2Dev Date: Fri, 12 Jan 2018 16:39:47 -0500 Subject: [PATCH 1/5] Enforce Integral Values for Various XBin Blocks --- xbin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xbin.py b/xbin.py index 4724e6b..a061262 100644 --- a/xbin.py +++ b/xbin.py @@ -458,7 +458,7 @@ def WritePartInfo(file, index, name): @staticmethod def WritePartIndex(file, index): - data = struct.pack('Hh', 0x745A, index) + data = struct.pack('Hh', 0x745A, int(index)) file.write(data) @staticmethod @@ -468,12 +468,12 @@ def WriteFramerate(file, framerate): @staticmethod def WriteFrameCount(file, frame_count): - data = struct.pack('Hxxi', 0xB917, frame_count) + data = struct.pack('Hxxi', 0xB917, int(frame_count)) file.write(data) @staticmethod def WriteFrameIndex(file, frame): - data = struct.pack('Hxxi', 0xC723, frame) + data = struct.pack('Hxxi', 0xC723, int(frame)) file.write(data) @staticmethod From 5e984d08cfe1a8861e49834853cdce03fa83ada4 Mon Sep 17 00:00:00 2001 From: SE2Dev Date: Fri, 12 Jan 2018 17:26:22 -0500 Subject: [PATCH 2/5] Enforce Padding for XBin Comment Blocks --- xbin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xbin.py b/xbin.py index a061262..38ea600 100644 --- a/xbin.py +++ b/xbin.py @@ -323,8 +323,9 @@ def WriteMetaVec4Block(file, _hash, vec): @staticmethod def WriteCommentBlock(file, comment): - comment = bytearray(comment.encode('utf-8')) - data = struct.pack('Hxx%ds' % (len(comment) + 1), 0xC355, comment) + comment = __str_packable__(comment) + padded_size = padded(len(comment) + 1) + data = struct.pack('Hxx%ds' % padded_size, 0xC355, comment) file.write(data) @staticmethod From 5a865e7f9fd8745006c581519802dfc321acfeea Mon Sep 17 00:00:00 2001 From: SE2Dev Date: Fri, 12 Jan 2018 17:29:49 -0500 Subject: [PATCH 3/5] Fix LZ4 Compression for Python-LZ4 --- _lz4.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_lz4.py b/_lz4.py index 2fd22eb..f6a3965 100644 --- a/_lz4.py +++ b/_lz4.py @@ -122,7 +122,10 @@ def compress(data): else: # Use python-lz4 if present __support_mode__ = 'python-lz4' - compress = lz4.block.compress + + def compress(data): + return lz4.block.compress(data, store_size=False) + uncompress = lz4.block.decompress support_info = 'LZ4: Using %s' % __support_mode__ From 20a29096d2c2721262c44151dfed21e97aebe4f4 Mon Sep 17 00:00:00 2001 From: SE2Dev Date: Sun, 14 Jan 2018 18:14:48 -0500 Subject: [PATCH 4/5] Fix byte2int() for Python 3 Provides a fix for byte2int() using the Python 2 implemention on Python 3 when the "six" module isn't present --- _lz4.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/_lz4.py b/_lz4.py index f6a3965..254e515 100644 --- a/_lz4.py +++ b/_lz4.py @@ -12,8 +12,15 @@ except ImportError: xrange = range - def byte2int(_bytes): - return ord(_bytes[0]) + # If we're running Python 3 or newer, we must + # define byte2int differently than with Python 2 + import sys + if sys.version_info[0] >= 3: + import operator + byte2int = operator.itemgetter(0) + else: + def byte2int(_bytes): + return ord(_bytes[0]) class CorruptError(Exception): pass From 6dbcb436bc419836b72ca752836a7ea6d1159bc0 Mon Sep 17 00:00:00 2001 From: SE2Dev Date: Sun, 14 Jan 2018 18:21:05 -0500 Subject: [PATCH 5/5] Bump Version from 0.2.0 -> 0.2.1 --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 1bba1e2..c89cec3 100644 --- a/__init__.py +++ b/__init__.py @@ -4,4 +4,4 @@ from .xanim import Anim from .sanim import SiegeAnim -version = (0, 2, 0) # Version specifier for PyCoD +version = (0, 2, 1) # Version specifier for PyCoD