Python code that I'm contributing to sc2reader's apm plugin