def load(self): """Load selected scenario and show strings""" if self.listbox.selected == -1: self._gui.findChild(name="hintlbl").text = u"Select a scenario first." else: self._gui.findChild(name="hintlbl").text = u"" # remember current entry cur_entry = self.logbook.get_cur_entry() cur_entry = cur_entry if cur_entry is not None else 0 self.logbook.clear() # get logbook actions from scenario file and add them to our logbook scenario_file_path = self.scenarios[0][self.listbox.selected] data = YamlCache.load_yaml_data(open(scenario_file_path, 'r')) events = data['events'] for event in events: for action in event['actions']: if action['type'] in ('logbook', 'logbook'): self.logbook.add_captainslog_entry(action['arguments'], show_logbook=False) try: self.logbook.set_cur_entry(cur_entry) except ValueError: pass # no entries self.logbook._redraw_captainslog() self.logbook.show()
def update_infos(self): """Updates the status label while scrolling the scenario list. No up- date to logbook messages. Those are loaded after Load/Reload is clicked. """ scenario_file_path = self.scenarios[0][self.listbox.selected] data = YamlCache.load_yaml_data(open(scenario_file_path, 'r')) stats = data.get('translation_status', '') # no stats available => empty label self.statslabel.text = unicode(stats)
def update_infos(self): """Updates the status label while scrolling the scenario list. No up- date to logbook messages. Those are loaded after Load/Reload is clicked. """ scenario_file_path = self.scenarios[0][self.listbox.selected] data = YamlCache.load_yaml_data(open(scenario_file_path, 'r')) try: stats = data['translation_status'] except KeyError as err: stats = '' # no translation stats available, display empty label self.statslabel.text = unicode(stats)
def _parse_yaml(string_or_stream): try: return YamlCache.load_yaml_data(string_or_stream) except Exception as e: # catch anything yaml or functions that yaml calls might throw raise InvalidScenarioFileFormat(str(e))