Stop polluting stdout.

This commit is contained in:
Elliot Nunn 2018-12-13 15:48:04 +08:00
parent 08b64758d4
commit b7739a449b
2 changed files with 9 additions and 10 deletions

View File

@ -100,9 +100,9 @@ def GreggDecompress(src, dst, unpackSize, pos=0):
hasDynamicTab = comprFlags & 1
isBitmapped = comprFlags & 2
print("tabSize: %d" % tabSize)
print("comprFlags: 0x%X, dynamic table: %s, bitmap data: %s" % (comprFlags,
"yes" if hasDynamicTab else "no", "yes" if isBitmapped else "no"))
# print("tabSize: %d" % tabSize)
# print("comprFlags: 0x%X, dynamic table: %s, bitmap data: %s" % (comprFlags,
# "yes" if hasDynamicTab else "no", "yes" if isBitmapped else "no"))
if hasDynamicTab:
nEntries = tabSize + 1
@ -223,4 +223,4 @@ def GreggCompress(src, dst, customTab='auto', isBitmapped='auto'):
if len(src) & 1: # copy over last byte in the case of odd length
dst.append(src[-1])
else:
print("Non-bitmapped compression not yet implemented")
raise ValueError("Non-bitmapped compression not yet implemented")

View File

@ -10,20 +10,19 @@ from .GreggBits import GreggDecompress, GreggCompress
def GetEncoding(dat):
sig, hdrlen, vers, attrs, biglen = struct.unpack_from(">IHBBI", dat)
if sig != 0xA89F6572:
print("Invalid extended resource header sig: 0x%X" % sig)
# print("Invalid extended resource header sig: 0x%X" % sig)
return 'UnknownCompression'
if vers not in (8, 9):
print("Unknown ext res header format: %d" % vers)
# print("Unknown ext res header format: %d" % vers)
return 'UnknownCompression'
if attrs & 1 == 0:
print("extAttributes,bit0 isn't set. Treat this res as uncompressed.")
# print("extAttributes,bit0 isn't set. Treat this res as uncompressed.")
return 'UnknownCompression'
print("Uncompressed length: %d" % biglen)
# print("Uncompressed length: %d" % biglen)
if vers == 8:
print('Donn unimplemented!'); return 'UnknownCompression'
return 'DonnBits'
return 'UnknownCompression' # return 'DonnBits'
elif vers == 9:
if dat[12:14] == b'\x00\x02':
return 'GreggyBits'