11from .parsers import *
22from .objects import *
33from .utils import AttributeDict , LITTLE_ENDIAN
4- import exceptions
4+ from . exceptions import ParseError , ReadError
55
66class InitDataReader (object ):
77 def __call__ (self ,buffer , replay ):
@@ -237,16 +237,16 @@ def __call__(self, buffer, replay):
237237 # If the type is not a key in the PARSERS lookup table we
238238 # probably incorrectly parsed the previous event
239239 # TODO: Raise an error instead an store the previous event
240- raise exceptions . ReadError ("Unknown event type" , type , code , start , replay , game_events , buffer )
240+ raise ReadError ("Unknown event type" , type , code , start , replay , game_events , buffer )
241241
242- except TypeError :
242+ except ParseError :
243243 # For some reason, the type handler that we delegated to didn't
244244 # recognize the event code that we extracated.
245245 # TODO: Do something meaningful here
246- raise exceptions . ReadError ("Unknown event code" , type , code , start , replay , game_events , buffer )
246+ raise ReadError ("Unknown event code" , type , code , start , replay , game_events , buffer )
247247
248- except exceptions . ReadError as e :
249- raise exceptions . ReadError (e .msg , replay , game_events , buffer , start )
248+ except ReadError as e :
249+ raise ReadError (e .msg , replay , game_events , buffer , start )
250250
251251 # Because events are parsed in a bitwise fashion, they sometimes
252252 # leave the buffer in a bitshifted state. Each new event always
@@ -265,7 +265,7 @@ def get_setup_parser(self, code):
265265 elif code in (0x05 ,): return self .parse_start_event
266266 else :
267267 # TODO: Raise a better error
268- raise exceptions . ReadError ("Unknown Setup Parser Code {0}" .format (code ))
268+ raise ReadError ("Unknown Setup Parser Code {0}" .format (code ))
269269
270270 def get_action_parser (self , code ):
271271 # The action events are always associated with a particular player and
@@ -277,7 +277,7 @@ def get_action_parser(self, code):
277277 elif code & 0x0F == 0xF : return self .parse_transfer_event
278278 else :
279279 # TODO: Raise a better error
280- raise exceptions . ReadError ("Unknown Action Parser Code {0}" .format (code ))
280+ raise ReadError ("Unknown Action Parser Code {0}" .format (code ))
281281
282282 def get_unknown2_parser (self , code ):
283283 # While its unclear what these events represent, they are MUCH more
@@ -288,7 +288,7 @@ def get_unknown2_parser(self, code):
288288 elif code == 0x0E : return self .parse_020E_event
289289 else :
290290 # TODO: Raise a better error
291- raise exceptions . ReadError ("Unknown Unknown2 Parser Code {0}" .format (code ))
291+ raise ReadError ("Unknown Unknown2 Parser Code {0}" .format (code ))
292292
293293 def get_camera_parser (self , code ):
294294 # Each player's camera control events are recorded, separately from the
@@ -301,7 +301,7 @@ def get_camera_parser(self, code):
301301 elif code == 0x0a : return self .parse_camera0A_event
302302 else :
303303 # TODO: Raise a better error
304- raise exceptions . ReadError ("Unknown Camera Parser Code {0}" .format (code ))
304+ raise ReadError ("Unknown Camera Parser Code {0}" .format (code ))
305305
306306 def get_unknown4_parser (self , code ):
307307 # I don't know anything about these events. Any parse information for
@@ -317,7 +317,7 @@ def get_unknown4_parser(self, code):
317317 elif code & 0x0F == 0x0C : return self .parse_04XC_event
318318 else :
319319 # TODO: Raise a better error
320- raise exceptions . ReadError ("Unknown Unknown4 Parser Code {0}" .format (code ))
320+ raise ReadError ("Unknown Unknown4 Parser Code {0}" .format (code ))
321321
322322# The storage format for many of the game events has changed, sometimes
323323# dramatically, over time. To handle this inconsistency sc2reader uses mixins
0 commit comments