Add debug logging for cblock read()

This commit is contained in:
Jan Petykiewicz 2018-07-21 14:04:59 -07:00
parent af60d73427
commit 9133245d49
2 changed files with 12 additions and 10 deletions

View File

@ -516,7 +516,7 @@ class NString:
""" """
return write_bstring(stream, self.bytes) return write_bstring(stream, self.bytes)
def __eq__(self, other) -> bool: def __eq__(self, other: 'NString') -> bool:
return isinstance(other, type(self)) and self.string == other.string return isinstance(other, type(self)) and self.string == other.string
def __repr__(self) -> str: def __repr__(self) -> str:
@ -608,7 +608,7 @@ class AString:
""" """
return write_bstring(stream, self.bytes) return write_bstring(stream, self.bytes)
def __eq__(self, other) -> bool: def __eq__(self, other: AString) -> bool:
return isinstance(other, type(self)) and self.string == other.string return isinstance(other, type(self)) and self.string == other.string
def __repr__(self) -> str: def __repr__(self) -> str:
@ -730,7 +730,7 @@ class ManhattanDelta:
""" """
return write_uint(stream, self.as_uint()) return write_uint(stream, self.as_uint())
def __eq__(self, other) -> bool: def __eq__(self, other: 'ManhattanDelta') -> bool:
return hasattr(other, as_list) and self.as_list() == other.as_list() return hasattr(other, as_list) and self.as_list() == other.as_list()
def __repr__(self) -> str: def __repr__(self) -> str:
@ -855,7 +855,7 @@ class OctangularDelta:
""" """
return write_uint(stream, self.as_uint()) return write_uint(stream, self.as_uint())
def __eq__(self, other) -> bool: def __eq__(self, other: 'OctangularDelta') -> bool:
return hasattr(other, as_list) and self.as_list() == other.as_list() return hasattr(other, as_list) and self.as_list() == other.as_list()
def __repr__(self) -> str: def __repr__(self) -> str:
@ -931,7 +931,7 @@ class Delta:
size += write_uint(stream, encode_sint(self.y)) size += write_uint(stream, encode_sint(self.y))
return size return size
def __eq__(self, other) -> bool: def __eq__(self, other: 'Delta') -> bool:
return hasattr(other, as_list) and self.as_list() == other.as_list() return hasattr(other, as_list) and self.as_list() == other.as_list()
def __repr__(self) -> str: def __repr__(self) -> str:
@ -977,7 +977,7 @@ class ReuseRepetition:
def write(self, stream: io.BufferedIOBase) -> int: def write(self, stream: io.BufferedIOBase) -> int:
return write_uint(stream, 0) return write_uint(stream, 0)
def __eq__(self, other) -> bool: def __eq__(self, other: 'ReuseRepetition') -> bool:
return isinstance(other, ReuseRepetition) return isinstance(other, ReuseRepetition)
def __repr__(self) -> str: def __repr__(self) -> str:
@ -1138,7 +1138,7 @@ class GridRepetition:
size += Delta(*self.b_vector).write(stream) size += Delta(*self.b_vector).write(stream)
return size return size
def __eq__(self, other) -> bool: def __eq__(self, other: 'GridRepetition') -> bool:
return isinstance(other, type(self)) and \ return isinstance(other, type(self)) and \
self.a_count == other.a_count and \ self.a_count == other.a_count and \
self.b_count == other.b_count and \ self.b_count == other.b_count and \
@ -1286,7 +1286,7 @@ class ArbitraryRepetition:
return size return size
def __eq__(self, other) -> bool: def __eq__(self, other: 'ArbitraryRepetition') -> bool:
return isinstance(other, type(self)) and self.x_displacements == other.x_displacements and self.y_displacements == other.y_displacements return isinstance(other, type(self)) and self.x_displacements == other.x_displacements and self.y_displacements == other.y_displacements
def __repr__(self) -> str: def __repr__(self) -> str:
@ -1483,7 +1483,7 @@ class PropStringReference:
self.ref = ref self.ref = ref
self.ref_type = ref_type self.ref_type = ref_type
def __eq__(self, other) -> bool: def __eq__(self, other: 'PropStringReference') -> bool:
return isinstance(other, type(self)) and self.ref == other.ref and self.reference_type == other.reference_type return isinstance(other, type(self)) and self.ref == other.ref and self.reference_type == other.reference_type
def __repr__(self) -> str: def __repr__(self) -> str:

View File

@ -487,7 +487,9 @@ class CBlock(Record):
compression_type = read_uint(stream) compression_type = read_uint(stream)
decompressed_count = read_uint(stream) decompressed_count = read_uint(stream)
compressed_bytes = read_bstring(stream) compressed_bytes = read_bstring(stream)
return CBlock(compression_type, decompressed_count, compressed_bytes) record = CBlock(compression_type, decompressed_count, compressed_bytes)
logger.debug('CBlock ending at 0x{:x} was read successfully'.format(stream.tell()))
return record
def write(self, stream: io.BufferedIOBase) -> int: def write(self, stream: io.BufferedIOBase) -> int:
size = write_uint(stream, 34) size = write_uint(stream, 34)