# Path: srs/models.py
# class TeamStats(models.Model):
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     stat_type = models.CharField(max_length=32)
#     stats = models.BinaryField(blank=True, null=True, default=None)
# 
#     graphid2label = OrderedDict(
#         (
#             ("metalUsed", "Metal Used"),
#             ("metalProduced", "Metal Produced"),
#             ("metalExcess", "Metal Excess"),
#             ("metalReceived", "Metal Received"),
#             ("metalSent", "Metal Sent"),
#             ("energyUsed", "Energy Used"),
#             ("energyProduced", "Energy Produced"),
#             ("energyExcess", "Energy Excess"),
#             ("energyReceived", "Energy Received"),
#             ("energySent", "Energy Sent"),
#             ("damageDealt", "Damage Dealt"),
#             ("damageReceived", "Damage Received"),
#             ("unitsProduced", "Units Produced"),
#             ("unitsKilled", "Units Killed"),
#             ("unitsDied", "Units Died"),
#             ("unitsReceived", "Units Received"),
#             ("unitsSent", "Units Sent"),
#             ("unitsCaptured", "Units Captured"),
#             ("unitsOutCaptured", "Units Stolen"),
#         )
#     )
# 
#     @property
#     def decompressed(self):
#         return ujson.loads(zlib.decompress(self.stats))
# 
#     @property
#     def label(self):
#         return self.graphid2label[self.stat_type]
# 
#     def __unicode__(self):
#         return "TeamStats(pk={}, replay.pk={}, stat_type={}, {!r}...)".format(
#             self.pk, self.replay.pk, self.stat_type, self.stats[:4]
#         )


import logging
import os.path
import plotly
import plotly.graph_objs as go
from collections import OrderedDict
from .models import TeamStats
from .SpringStatsViewer.SpringDemoFile import DemoFileReader
    from typing import Dict, List, Optional, Tuple, Union
    from SpringStatsViewer.SpringDemoFile import TeamStatistics
# This file is part of the "spring relay site / srs" program. It is published
# under the GPLv3.
#
# Copyright (C) 2018 Daniel Troeder (daniel #at# admin-box #dot# com)
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




try:

except ImportError:
    pass


logger = logging.getLogger(__name__)


class MatchStatsGeneration(object):
    def __init__(self, file_path):
        self.file_path = os.path.abspath(file_path)
        self.demofile = DemoFileReader(self.file_path)

    def make_teamstat_graphs(cls, teamstats):
        # type: (Dict[str, List[TeamStatistics]]) -> Dict[str, Dict[str, List[float]]]
        res = OrderedDict()  # type: Dict

# Path: srs/models.py
# class TeamStats(models.Model):
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     stat_type = models.CharField(max_length=32)
#     stats = models.BinaryField(blank=True, null=True, default=None)
# 
#     graphid2label = OrderedDict(
#         (
#             ("metalUsed", "Metal Used"),
#             ("metalProduced", "Metal Produced"),
#             ("metalExcess", "Metal Excess"),
#             ("metalReceived", "Metal Received"),
#             ("metalSent", "Metal Sent"),
#             ("energyUsed", "Energy Used"),
#             ("energyProduced", "Energy Produced"),
#             ("energyExcess", "Energy Excess"),
#             ("energyReceived", "Energy Received"),
#             ("energySent", "Energy Sent"),
#             ("damageDealt", "Damage Dealt"),
#             ("damageReceived", "Damage Received"),
#             ("unitsProduced", "Units Produced"),
#             ("unitsKilled", "Units Killed"),
#             ("unitsDied", "Units Died"),
#             ("unitsReceived", "Units Received"),
#             ("unitsSent", "Units Sent"),
#             ("unitsCaptured", "Units Captured"),
#             ("unitsOutCaptured", "Units Stolen"),
#         )
#     )
# 
#     @property
#     def decompressed(self):
#         return ujson.loads(zlib.decompress(self.stats))
# 
#     @property
#     def label(self):
#         return self.graphid2label[self.stat_type]
# 
#     def __unicode__(self):
#         return "TeamStats(pk={}, replay.pk={}, stat_type={}, {!r}...)".format(
#             self.pk, self.replay.pk, self.stat_type, self.stats[:4]
#         )


# Path: srs/match_stats.py
import logging
import os.path
import plotly
import plotly.graph_objs as go
from collections import OrderedDict
from .models import TeamStats
from .SpringStatsViewer.SpringDemoFile import DemoFileReader
    from typing import Dict, List, Optional, Tuple, Union
    from SpringStatsViewer.SpringDemoFile import TeamStatistics

# This file is part of the "spring relay site / srs" program. It is published
# under the GPLv3.
#
# Copyright (C) 2018 Daniel Troeder (daniel #at# admin-box #dot# com)
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




try:

except ImportError:
    pass


logger = logging.getLogger(__name__)


class MatchStatsGeneration(object):
    def __init__(self, file_path):
        self.file_path = os.path.abspath(file_path)
        self.demofile = DemoFileReader(self.file_path)

    def make_teamstat_graphs(cls, teamstats):
        # type: (Dict[str, List[TeamStatistics]]) -> Dict[str, Dict[str, List[float]]]
        res = OrderedDict()  # type: Dict

        for ts_attr, label in TeamStats.graphid2label.items():