Mercurial > touhou
diff pytouhou/formats/anm0.py @ 377:70e2ed71b09c
Add meaningful exceptions in format parsing.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 29 Aug 2012 18:34:28 +0200 |
parents | da53bc29b94a |
children | 88e2a2485b2b |
line wrap: on
line diff
--- a/pytouhou/formats/anm0.py +++ b/pytouhou/formats/anm0.py @@ -23,6 +23,8 @@ Almost everything rendered in the game i from struct import pack, unpack from pytouhou.utils.helpers import read_string, get_logger +from pytouhou.formats import WrongFormatError + logger = get_logger(__name__) @@ -84,9 +86,8 @@ class ANM0(object): first_name_offset, unused, secondary_name_offset = unpack('<III', file.read(12)) version, unknown2, thtxoffset, hasdata, nextoffset, zero2 = unpack('<IIIIII', file.read(24)) if version != 0: - raise Exception #TODO - if (zero1, zero2) != (0, 0): - raise Exception #TODO + raise WrongFormatError(version) + assert (zero1, zero2) == (0, 0) sprite_offsets = [unpack('<I', file.read(4))[0] for i in range(nb_sprites)] script_offsets = [unpack('<II', file.read(8)) for i in range(nb_scripts)]