Example #1
0
    def __init__(self, replay_file, **options):
        #Useful references
        self.opt = AttributeDict(**options)

        # Some file-like objects may not support filenames. Issue #21
        if hasattr(replay_file, 'name'):
            self.filename = replay_file.name
        else:
            self.filename = "Unavailable"

        #header information
        self.versions,self.frames = read_header(replay_file)
        self.build = self.versions[4]
        self.release_string = "%s.%s.%s.%s" % tuple(self.versions[1:5])
        self.seconds = self.frames/16
        self.length = Length(seconds=self.seconds)

        #default values, filled in during file read
        self.player_names = list()
        self.other_people = set()
        self.speed = ""
        self.type = ""
        self.category = ""
        self.is_ladder = False
        self.is_private = False
        self.map = ""
        self.gateway = ""
        self.events = list()
        self.events_by_type = defaultdict(list)
        self.results = dict()
        self.teams = list()
        self.team = dict()
        self.observers = list() #Unordered list of Observer
        self.players = list() #Unordered list of Player
        self.player = PersonDict()
        self.people = list() #Unordered list of Players+Observers
        self.humans = list() #Unordered list of Human People
        self.person = PersonDict() #Maps pid to Player/Observer
        self.attributes = list()
        self.messages = list()
        self.recorder = None # Player object
        self.winner_known = False
        self.packets = list()
        # Set in parsers.DetailParser.load, should we hide this?
        self.file_time = None

        # TODO: Test EPOCH differences between MacOsX and Windows
        # http://en.wikipedia.org/wiki/Epoch_(reference_date)
        # Notice that Windows and Mac have different EPOCHs, I wonder whether
        # this is different depending on the OS on which the replay was played.
        self.date = None # Date when the game was played in local time
        self.utc_date = None # Date when the game was played in UTC

        self.objects = {}
        self.raw = AttributeDict()
Example #2
0
    def __init__(self, replay_file, **options):
        #Useful references
        self.opt = AttributeDict(**options)

        # Some file-like objects may not support filenames. Issue #21
        if hasattr(replay_file, 'name'):
            self.filename = replay_file.name
        else:
            self.filename = "Unavailable"

        #header information
        self.versions, self.frames = read_header(replay_file)
        self.build = self.versions[4]
        self.release_string = "%s.%s.%s.%s" % tuple(self.versions[1:5])
        self.seconds = self.frames / 16
        self.length = Length(seconds=self.seconds)

        #default values, filled in during file read
        self.player_names = list()
        self.other_people = set()
        self.speed = ""
        self.type = ""
        self.category = ""
        self.is_ladder = False
        self.is_private = False
        self.map = ""
        self.gateway = ""
        self.events = list()
        self.events_by_type = defaultdict(list)
        self.results = dict()
        self.teams = list()
        self.team = dict()
        self.observers = list()  #Unordered list of Observer
        self.players = list()  #Unordered list of Player
        self.player = PersonDict()
        self.people = list()  #Unordered list of Players+Observers
        self.humans = list()  #Unordered list of Human People
        self.person = PersonDict()  #Maps pid to Player/Observer
        self.attributes = list()
        self.messages = list()
        self.recorder = None  # Player object
        self.winner_known = False
        self.packets = list()
        # Set in parsers.DetailParser.load, should we hide this?
        self.file_time = None

        # TODO: Test EPOCH differences between MacOsX and Windows
        # http://en.wikipedia.org/wiki/Epoch_(reference_date)
        # Notice that Windows and Mac have different EPOCHs, I wonder whether
        # this is different depending on the OS on which the replay was played.
        self.date = None  # Date when the game was played in local time
        self.utc_date = None  # Date when the game was played in UTC

        self.objects = {}
        self.raw = AttributeDict()
Example #3
0
    def __init__(self, replay_file, filename=None, **options):
        super(Replay, self).__init__(replay_file, filename, **options)
        self.datapack = None
        self.raw_data = dict()
        self.listeners = defaultdict(list)

        self.__dict__.update(utils.read_header(replay_file))
        self.archive = utils.open_archive(replay_file)

        #default values, filled in during file read
        self.player_names = list()
        self.other_people = set()
        self.speed = ""
        self.type = ""
        self.category = ""
        self.is_ladder = False
        self.is_private = False
        self.map = ""
        self.gateway = ""
        self.events = list()
        self.events_by_type = defaultdict(list)
        self.results = dict()

        self.teams, self.team = list(), dict()
        self.players, self.player = list(), utils.PersonDict()
        self.observers = list() #Unordered list of Observer

        self.people, self.humans = list(), list() #Unordered list of Players+Observers

        self.person = utils.PersonDict() #Maps pid to Player/Observer
        self.attributes = list()
        self.messages = list()
        self.recorder = None # Player object
        self.packets = list()

        self.objects = {}
Example #4
0
    def __init__(self, replay_file, filename=None, load_level=4, **options):
        super(Replay, self).__init__(replay_file, filename, **options)
        self.datapack = None
        self.raw_data = dict()

        #default values, filled in during file read
        self.player_names = list()
        self.other_people = set()
        self.speed = ""
        self.type = ""
        self.os = str()
        self.game_type = ""
        self.real_type = ""
        self.category = ""
        self.is_ladder = False
        self.is_private = False
        self.map = None
        self.map_hash = ""
        self.gateway = ""
        self.events = list()
        self.events_by_type = defaultdict(list)
        self.results = dict()
        self.teams, self.team = list(), dict()
        self.players, self.player = list(), utils.PersonDict()
        self.observers = list() #Unordered list of Observer
        self.people, self.humans = list(), list() #Unordered list of Players+Observers
        self.person = utils.PersonDict() #Maps pid to Player/Observer
        self.attributes = defaultdict(dict)
        self.messages = list()
        self.recorder = None # Player object
        self.packets = list()
        self.objects = {}

        # Bootstrap the readers.
        self.registered_readers = defaultdict(list)
        self.register_default_readers()

        # Bootstrap the datapacks.
        self.registered_datapacks= list()
        self.register_default_datapacks()

        # Unpack the MPQ and read header data if requested
        if load_level >= 0:
            # Set ('versions', 'frames', 'build', 'release_string', 'length')
            self.__dict__.update(utils.read_header(replay_file))
            self.expansion = ['','WoL','HotS'][self.versions[1]]
            self.archive = utils.open_archive(replay_file)

        # Load basic details if requested
        if load_level >= 1:
            for data_file in ['replay.initData','replay.details','replay.attributes.events']:
                self._read_data(data_file, self._get_reader(data_file))
            self.load_details()
            self.datapack = self._get_datapack()

            # Can only be effective if map data has been loaded
            if options.get('load_map', False):
                self.load_map()

        # Load players if requested
        if load_level >= 2:
            for data_file in ['replay.message.events']:
                self._read_data(data_file, self._get_reader(data_file))
            self.load_messages()
            self.load_players()

        # Load events if requested
        if load_level >= 3:
            for data_file in ['replay.game.events']:
                self._read_data(data_file, self._get_reader(data_file))
            self.load_events()