Beispiel #1
0
def main():
    print "HI!"
    parser = argparse.ArgumentParser(
        description=
        'Prints basic information from SC2 replay files or directories.')
    parser.add_argument(
        'paths',
        metavar='filename',
        type=str,
        nargs='+',
        help="Paths to one or more SC2Replay files or directories")
    parser.add_argument('--date',
                        action="store_true",
                        default=True,
                        help="Print game date")
    parser.add_argument(
        '--length',
        action="store_true",
        default=False,
        help="Print game duration mm:ss in game time (not real time)")
    parser.add_argument('--map',
                        action="store_true",
                        default=True,
                        help="Print map name")
    parser.add_argument('--messages',
                        action="store_true",
                        default=False,
                        help="Print in-game player chat messages")
    parser.add_argument(
        '--teams',
        action="store_true",
        default=True,
        help="Print teams, their players, and the race matchup")
    parser.add_argument('--version',
                        action="store_true",
                        default=True,
                        help="Print the release string as seen in game")
    parser.add_argument('--recursive',
                        action="store_true",
                        default=True,
                        help="Recursively read through directories of replays")

    arguments = parser.parse_args()

    for path in arguments.paths:
        if arguments.recursive:
            files = get_files(path)
        else:
            files = get_files(path, depth=0)

        for file in files:
            print "\n--------------------------------------\n{0}\n".format(
                file)
            doFile(file, arguments)
Beispiel #2
0
    def _load_resources(self, resources, options=None, **new_options):
        """Collections of resources or a path to a directory"""
        options = options or self._get_options(Resource, **new_options)

        # Path to a folder, retrieve all relevant files as the collection
        if isinstance(resources, basestring):
            resources = utils.get_files(resources, **options)

        for resource in resources:
            yield self._load_resource(resource, options=options)
Beispiel #3
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Prints basic information from SC2 replay files or directories.')
    parser.add_argument(
        'paths',
        metavar='filename',
        type=str,
        nargs='+',
        help="Paths to one or more SC2Replay files or directories")
    parser.add_argument('--date',
                        action="store_true",
                        default=True,
                        help="Print game date")
    parser.add_argument(
        '--length',
        action="store_true",
        default=False,
        help="Print game duration mm:ss in game time (not real time)")
    parser.add_argument('--map',
                        action="store_true",
                        default=True,
                        help="Print map name")
    parser.add_argument('--messages',
                        action="store_true",
                        default=False,
                        help="Print in-game player chat messages")
    parser.add_argument(
        '--teams',
        action="store_true",
        default=True,
        help="Print teams, their players, and the race matchup")
    parser.add_argument('--version',
                        action="store_true",
                        default=True,
                        help="Print the release string as seen in game")
    parser.add_argument('--recursive',
                        action="store_true",
                        default=True,
                        help="Recursively read through directories of replays")

    arguments = parser.parse_args()
    for path in arguments.paths:
        depth = -1 if arguments.recursive else 0
        for filepath in utils.get_files(path, depth=depth):
            name, ext = os.path.splitext(filepath)
            if ext.lower() == '.sc2replay':
                print "\n--------------------------------------\n{0}\n".format(
                    filepath)
                printReplay(filepath, arguments)
            elif ext.lower() == '.s2gs':
                print "\n--------------------------------------\n{0}\n".format(
                    filepath)
                printGameSummary(filepath, arguments)
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser(description='Prints all events from SC2 replay files or directories.')
    parser.add_argument('paths', metavar='filename', type=str, nargs='+',
                        help="Paths to one or more SC2Replay files or directories")
    parser.add_argument('-n', metavar='numevents', type=int,
                        help="Number of events to read")
    arguments = parser.parse_args()

    print arguments.n

    for path in arguments.paths:
        files = get_files(path, depth=0)

        for file in files:
            print "\n--------------------------------------\n{0}\n".format(file)
            doFile(file, arguments)
Beispiel #5
0
    def read(self, location, **user_options):
        """ Read indicated file or recursively read matching files from the
            specified directory. Returns a replay or a list of replays depending
            on the context.
        """

        # Base the options off a copy to leave the Reader options uneffected.
        options = self.options.copy()
        options.update(user_options)

        # The directory option allows users to specify file locations relative
        # to a location other than the present working directory by joining the
        # location with the directory of their choice.
        if options.directory:
            location = os.path.join(options.directory, location)

        # When passed a directory as the location, the Reader recursively builds
        # a list of replays to return using the utils.get_files function. This
        # function respects the following arguments:
        #   * depth: The maximum depth to traverse. Defaults to unlimited (-1)
        #   * follow_symlinks: Boolean for following symlinks. Defaults to True
        #   * exclude_dirs: A list of directory names to skip while recursing
        #   * incldue_regex: A regular expression rule which all returned file
        #       names must match. Defaults to None
        #
        replays, files = list(), utils.get_files(location, **options)

        # If no files are found, it could be for a variety of reasons
        # raise a NoMatchingFilesError to alert them to the situation
        if not files:
            raise exceptions.NoMatchingFilesError()

        for location in files:
            if options.verbose: print "Reading: %s" % location

            with open(location, 'rb') as replay_file:
                replays.append(self.make_replay(replay_file, **options))

        return replays
Beispiel #6
0
def main():
    parser = argparse.ArgumentParser(
        description="""Prints basic information from Starcraft II replay and
        game summary files or directories.""")
    parser.add_argument(
        '--recursive',
        action="store_true",
        default=True,
        help=
        "Recursively read through directories of Starcraft II files [default on]"
    )

    required = parser.add_argument_group('Required Arguments')
    required.add_argument(
        'paths',
        metavar='filename',
        type=str,
        nargs='+',
        help="Paths to one or more Starcraft II files or directories")

    shared_args = parser.add_argument_group('Shared Arguments')
    shared_args.add_argument('--date',
                             action="store_true",
                             default=True,
                             help="print(game date [default on]")
    shared_args.add_argument(
        '--length',
        action="store_true",
        default=False,
        help=
        "print(game duration mm:ss in game time (not real time) [default off]")
    shared_args.add_argument('--map',
                             action="store_true",
                             default=True,
                             help="print(map name [default on]")
    shared_args.add_argument(
        '--teams',
        action="store_true",
        default=True,
        help="print(teams, their players, and the race matchup [default on]")

    replay_args = parser.add_argument_group('Replay Options')
    replay_args.add_argument(
        '--messages',
        action="store_true",
        default=False,
        help="print(in-game player chat messages [default off]")
    replay_args.add_argument(
        '--version',
        action="store_true",
        default=True,
        help="print(the release string as seen in game [default on]")

    s2gs_args = parser.add_argument_group('Game Summary Options')
    s2gs_args.add_argument(
        '--builds',
        action="store_true",
        default=False,
        help="print(player build orders (first 64 items) [default off]")

    arguments = parser.parse_args()
    for path in arguments.paths:
        depth = -1 if arguments.recursive else 0
        for filepath in utils.get_files(path, depth=depth):
            name, ext = os.path.splitext(filepath)
            if ext.lower() == '.sc2replay':
                print("\n--------------------------------------\n{0}\n".format(
                    filepath))
                printReplay(filepath, arguments)
            elif ext.lower() == '.s2gs':
                print("\n--------------------------------------\n{0}\n".format(
                    filepath))
                printGameSummary(filepath, arguments)
Beispiel #7
0
def main():
    parser = argparse.ArgumentParser(
        description=
        """Prints PAC information from Starcraft II replay files or directories."""
    )
    parser.add_argument(
        '--recursive',
        action="store_false",
        default=True,
        help=
        "Recursively read through directories of Starcraft II files [default on]"
    )

    required = parser.add_argument_group('Required Arguments')
    required.add_argument(
        'paths',
        metavar='filename',
        type=str,
        nargs='+',
        help="Paths to one or more Starcraft II files or directories")

    display = parser.add_argument_group('Display Options')
    display.add_argument('--pausestats',
                         action="store_false",
                         default=True,
                         help="Pauses after each stat block [default on]")
    display.add_argument('--pausereplays',
                         action="store_true",
                         default=False,
                         help="Pauses after each replay summary [default off]")
    display.add_argument(
        '--displayreplays',
        action="store_true",
        default=False,
        help="Displays individual replay summaries [default off]")

    arguments = parser.parse_args()
    analysis = {}
    depth = -1 if arguments.recursive else 0
    replays = set(filepath for path in arguments.paths
                  for filepath in utils.get_files(path, depth=depth)
                  if os.path.splitext(filepath)[1].lower() == '.sc2replay')
    replayCount = len(replays)

    if replayCount == 1:
        arguments.displayreplays = True
        arguments.pausereplays = True

    for replay in replays:
        try:
            printReplay(replay, analysis, arguments)
        except:
            print("Error with '{0}': ".format(replay))
            replayCount -= 1
        if arguments.pausereplays:
            print("PRESS ENTER TO CONTINUE")
            input()

    if replayCount > 1:
        print("\n--------------------------------------")
        print("Results - {0} Replays Analyzed".format(replayCount))
        print("{0} Players Analyzed".format(len(analysis)))
        for stats in sorted(analysis.items(),
                            key=lambda t: t[1].count,
                            reverse=True):
            print("\t{0:<15} (pid: {1})\t- {2} replays".format(
                stats[1].name, stats[0], stats[1].count))
            print("\t\tPPM: {0:>6.2f}".format(stats[1].ppm))
            print("\t\tPAL: {0:>6.2f}".format(stats[1].pal))
            print("\t\tAPP: {0:>6.2f}".format(stats[1].app))
            print("\t\tGAP: {0:>6.2f}".format(stats[1].gap))
            if arguments.pausestats:
                print("PRESS ENTER TO CONTINUE")
                input()
Beispiel #8
0
from distutils.core import setup
import py2exe
import os
from sc2reader import utils


importDir = 'c:/Users/Xanthus/Documents/GitHub/sc2reader/sc2reader/data'
baseDir = 'c:/Users/Xanthus/Documents/GitHub/sc2reader'
Mydata_files = []
for filepath in utils.get_files(importDir, depth=-1):
    relPath = os.path.relpath(filepath, baseDir)
    path, file = os.path.split(relPath)
    ext = os.path.splitext(relPath)[1]
    if ext == '.csv' or ext == '.json':
        Mydata_files.append((os.path.normpath(path), [os.path.normpath(filepath)]))
setup(
    data_files=Mydata_files,
    zipfile=None,
    options={'py2exe':{
        'optimize':2,
        'bundle_files':0,
        'compressed':True
    }},
    console=['sc2reader/scripts/PACAnalysis.py']
    )