Mercurial > mamba
comparison mamba/level.py @ 342:868a53b96c29
Protect against malformed sprite lines
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Fri, 16 Sep 2011 22:02:38 +0200 |
parents | 0c25bca380de |
children | 5bf35267ddc0 |
comparison
equal
deleted
inserted
replaced
341:e769032e3c09 | 342:868a53b96c29 |
---|---|
198 | 198 |
199 def setup_sprites(self, sprites_ascii): | 199 def setup_sprites(self, sprites_ascii): |
200 self.extra_sprites = {} | 200 self.extra_sprites = {} |
201 sprite_positions = [] | 201 sprite_positions = [] |
202 for sprite_ascii in sprites_ascii: | 202 for sprite_ascii in sprites_ascii: |
203 pos, _sep, rest = sprite_ascii.partition(':') | 203 try: |
204 pos, _sep, rest = sprite_ascii.partition(':') | |
205 except ValueError: | |
206 raise InvalidMapError('Unable to determine sprite position' | |
207 ' from line: %s' % sprite_ascii) | |
204 try: | 208 try: |
205 pos = [int(x.strip()) for x in pos.split(',')] | 209 pos = [int(x.strip()) for x in pos.split(',')] |
206 except ValueError: | 210 except ValueError: |
207 raise InvalidMapError("Sprite position must be two integers." | 211 raise InvalidMapError("Sprite position must be two integers." |
208 "Got %s" % pos) | 212 "Got %s" % pos) |