Permalink
Browse files

Add method for reading 1 bit flags.

  • Loading branch information...
1 parent 2b480d4 commit 84a82efe11ec71b4d44ded49046cacbea4a63da9 @GraylinKim committed Mar 10, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 sc2reader/decoders.py
View
@@ -4,6 +4,7 @@
from cStringIO import StringIO
import struct
+import functools
class ByteDecoder(object):
@@ -119,6 +120,7 @@ def __init__(self, contents):
# Reduce the number of lookups required to read
self._read = self._buffer.read
+ self.read_bool = functools.partial(self.read_bits, 1)
def done(self):
""" Returns true when all bits in the buffer have been used"""
@@ -294,7 +296,7 @@ def read_struct(self, datatype=None):
elif datatype == 0x01: # bitarray, weird alignment requirements
bits = self.read_vint()
data = self.read_bits(bits)
-
+
elif datatype == 0x02: # blob
length = self.read_vint()
data = self.read_bytes(length)
@@ -327,7 +329,6 @@ def read_struct(self, datatype=None):
data = self.read_vint()
else:
- if debug: print prefix
raise TypeError("Unknown Data Structure: '%s'" % datatype)
return data

0 comments on commit 84a82ef

Please sign in to comment.