aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive
diff options
context:
space:
mode:
Diffstat (limited to 'FuseArchive')
-rw-r--r--FuseArchive/Chunk.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/FuseArchive/Chunk.py b/FuseArchive/Chunk.py
index 9f12f83..9bb05bd 100644
--- a/FuseArchive/Chunk.py
+++ b/FuseArchive/Chunk.py
@@ -8,7 +8,9 @@ import struct, zlib, logging
hformat = 'HLBL48x'
compress_level = 6
-assert struct.calcsize( hformat ) == 64, \
+header_length = 64
+
+assert struct.calcsize( hformat ) == header_length, \
"Header struct must be 64 bytes not %d bytes" % \
struct.calcsize( hformat )
@@ -57,15 +59,15 @@ class Chunk:
@staticmethod
def deserialize(data):
logging.debug( "Deserializing data of length %d" % len( data ) )
- hd = Chunk.parse_header( data[ :64 ] )
+ hd = Chunk.parse_header( data[ :header_length ] )
obj = Chunk()
obj.count = hd[ 'count' ]
compression = hd[ 'compression' ]
if compression == 0:
- obj.chunk = data[ 64: ]
+ obj.chunk = data[ header_length: ]
elif compression == 1:
- obj.chunk = zlib.decompress( data[64: ] )
+ obj.chunk = zlib.decompress( data[ header_length: ] )
else:
raise ValueError( "Invalid compression type: %d" % compression )