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: if arguments.recursive: files = utils.get_replay_files(path) else: files = utils.get_replay_files(path, depth=0) for file in files: print "\n--------------------------------------\n{0}\n".format(file) doFile(file, arguments)
def load_resources(self, resources, resource_loader, options=None, **new_options): """ Loads the specified set of resources using the current factory settings with specified overrides. :param resources: Either a path/url or a mixed collection of directories, paths/urls, and open file objects. :param None options: When options are passed directly into the options parameter the current factory settings are ignored and only the specified options are used during replay load. :param new_options: Options values to override current factory settings for the collection of replays to be loaded. :rtype: generator(Resource) """ options = options or utils.merged_dict(self.options, new_options) # Path to a resource? if isinstance(resources, basestring): if re.match(r'https?://',resources): yield resource_loader(resources, options=options) else: for resource in utils.get_replay_files(resources, **options): yield resource_loader(resource, options=options) # File like object? elif hasattr(resources,'read'): yield resource_loader(resources, options=options) # Collection of the above else: for resource in resources: yield resource_loader(resource, options=options)