GraylinKim / sc2reader

A python library that extracts data from various Starcraft II resources to power tools and services for the SC2 community. Who doesn't want to hack on the games they play?
http://sc2reader.readthedocs.org
MIT License
413 stars 85 forks source link

`None` in game events #188

Open StoicLoofah opened 9 years ago

StoicLoofah commented 9 years ago

I got this error with this replay

http://lotv.spawningtool.com/2178/download/

>>> import sc2reader
>>> sc2reader.load_replay('replays/beta/asl.SC2Replay')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kevin/sc2reader/sc2reader/factories/sc2factory.py", line 85, in load_replay
    return self.load(Replay, source, options, **new_options)
  File "/home/kevin/sc2reader/sc2reader/factories/sc2factory.py", line 137, in load
    return self._load(cls, resource, filename=filename, options=options)
  File "/home/kevin/sc2reader/sc2reader/factories/sc2factory.py", line 146, in _load
    obj = cls(resource, filename=filename, factory=self, **options)
  File "/home/kevin/sc2reader/sc2reader/resources.py", line 299, in __init__
    self.load_game_events()
  File "/home/kevin/sc2reader/sc2reader/resources.py", line 509, in load_game_events
    self.events = sorted(self.events+self.game_events, key=lambda e: e.frame)
  File "/home/kevin/sc2reader/sc2reader/resources.py", line 509, in <lambda>
    self.events = sorted(self.events+self.game_events, key=lambda e: e.frame)
AttributeError: 'NoneType' object has no attribute 'frame'

I think the fix is just to add this just before here

self.game_events = [event for event in self.game_events if event is not None]

I can open a PR for this, but I"m not sure this ist he right thing to do, and I would prefer to merge it onto the lotv branch, but that one hasn't been merged yet