grahamjenson/sc2reader — comment on commit 0c054a5393efc1c227265329e24f7652805ea15d
File: findUnkownAbilities.py line 43
By GraylinKim:

``sc2reader.load_replays`` is actually implemented as a generator, so the following loop should have the same performance characteristics. Additionally, a reference to the data back is already attached to the replay. A cool trick for printing out player information is using the (also undocumented) ``player.format`` method as shown below. In addition to a player list, there is also a dual key (name and pid) dictionary lookup you can use to grab the players. Finally, the player class (this part is documented, w00!) has an ``events`` attribute that has already done some of this work for you.

```python
from collections import defaultdict

versiontounknown = defaultdict(set)
player_format = "{name} {play_race}"
for x, rep in enumerate(sc2reader.load_replays(replays)):
config = rep.databack
print x, rep.filename, rep.player[1].format(player_format), ":", rep.player[2].format(player_format)

player1build = getBuild(rep.player[1].events)
player2build = getBuild(rep.player[2].events)
for build in (player1build,player2build):
for e in build :
abil = config.ability(e.ability)
if abil["type"] == "UNKNOWN":
versiontounknown[returnVersion(rep.build)].add(hex(e.ability))
```

Probably at the time you wrote this, the documentation was wrong or missing. It is slowly being filled in though.

Just thought I'd write in some notes while I looked around...