Пример #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division

import logging
import os
import argparse
import shutil
import SocketServer

# Set up sc2reader
import sc2reader
from sc2reader.factories.plugins.replay import toJSON
sc2reader.register_plugin("Replay", toJSON(encoding='UTF-8', indent=None))

# Set up logging
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(
    fmt='%(asctime)s - %(name)s [%(levelname)s] - %(message)s',
    datefmt='%Y%m%dT%H%M%S'
))
logger = logging.getLogger('sc2json')
logger.setLevel(logging.INFO)
logger.addHandler(handler)


# Create our socket server
class ReplayParser(SocketServer.StreamRequestHandler):
    def handle(self):
        path = self.rfile.readline().strip()
        logger.info("Parsing replay file: {}".format(path))
Пример #2
0
import sc2reader, os, sys
from sc2reader.plugins.replay import APMTracker, SelectionTracker

sc2reader.register_plugin('Replay', APMTracker())

class ProcessedReplays:

        def __init__(self, username, path):
            """
            The processed replays object represents the collection of replays loaded by
            the user, and the processed data associated with it.

            self.apm is a dictionary keyed by date (yyyy-mm-dd hh:mm:ss) containing the 
            average APM on that datetime

            Self.wr is a dictionary ordered by the race played by the active player,
            then subdictionaries of the race played by the opponent, which each have
            a two-item list: wins and total games. (This is not a tuple because tuples are immutable) 
            
            >>> p = ProcessedReplays('bonywonix', 'replays/')
            >>> p.me
            'bonywonix'
            >>> type(p.replays) is list
            True
            >>> type(p.wr) is dict
            True
            >>> p.replays[0].real_type != '1v1'
            False
            """
            self.me = username 
            self.apm = {}