def player_info(self, base_prefix, snapshot=None): """ Return current player info, based on properties :startswith: each key starts with this :returns: snapshot with current state but as if n the stack """ if snapshot is None: snapshot = SlTrace.snapshot_properties() if not base_prefix.endswith("."): base_prefix += "." sn = snapshot.snapshot_properties(sn=snapshot, req_match=re.escape(base_prefix) + r'\d+\.\w+') pp = PlayerProp(self.player_control) player_info = pp.get_player_infos(snapshot=sn) return player_info[0]
def player_infos(self, base_prefix, snapshot=None, sect_name=None): """ Get current stack of player infos :base_prefix: prop key beginning prefix :snapshot: information snapshot default: current snapshot :sect_name: section name e.g. "undo" sect_num: number 1 being last pushed """ if snapshot is None: snapshot = SlTrace.snapshot_properties() if not base_prefix.endswith("."): base_prefix += "." sn = snapshot.snapshot_properties(sn=snapshot, req_match=re.escape(base_prefix) + sect_name + r'\.') pp = PlayerProp(self.player_control, sect_name=sect_name) player_infos = pp.get_player_infos(snapshot=sn) return player_infos
def get_player_infos(self, snapshot=None): """ :returns: list of PlayerInfo in decending order of num to add to stack """ if snapshot is None: snapshot = SlTrace.snapshot_properties() prop_keys = snapshot.getPropKeys() for prop_key in prop_keys: prop_fields = prop_key.split(".") if prop_fields[0] != self.control_prefix: continue # Not this group if self.sect_name == None: self.add_player_prop(prop_fields) elif self.sect_name == "undo" or self.sect_name == "redo": self.add_sect_prop(prop_fields) infos = [] for key in sorted(self.sect_parts.keys()): infos.append(self.sect_parts[key]) return infos