def _upgrade_to_rev73(self, db):
		# Attempt to fix up corrupt yaml dumped into scenario savegames (#2164)
		key = 'scenario_events'
		try:
			yaml_data = db("SELECT name, value FROM metadata WHERE name = ?", key)[0][1]
		except IndexError:
			# Not a scenario, nothing to repair
			return
		try:
			YamlCache.load_yaml_data(yaml_data)
		except ParserError:
			messed_up = 'events: [ { actions: [ {'
			yaml_data = yaml_data.replace(messed_up, '}, ' + messed_up)
			db("UPDATE metadata SET value = ? WHERE name = ?", yaml_data, key)
Пример #2
0
 def _upgrade_to_rev73(self, db):
     # Attempt to fix up corrupt yaml dumped into scenario savegames (#2164)
     key = 'scenario_events'
     try:
         yaml_data = db("SELECT name, value FROM metadata WHERE name = ?",
                        key)[0][1]
     except IndexError:
         # Not a scenario, nothing to repair
         return
     try:
         YamlCache.load_yaml_data(yaml_data)
     except ParserError:
         messed_up = 'events: [ { actions: [ {'
         yaml_data = yaml_data.replace(messed_up, '}, ' + messed_up)
         db("UPDATE metadata SET value = ? WHERE name = ?", yaml_data, key)
	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()
Пример #4
0
    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)
Пример #6
0
    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 test_build_menu_consistency():
	"""
	Check that the same buildings are referenced in both configurations of the build menu.
	"""
	assert len(BuildTab.build_menus) == 2, 'Expected 2 build menu configs'

	buildings = []
	for filename in BuildTab.build_menus:
		with open(os.path.join(ROOT_DIR, filename)) as f:
			data = YamlCache.load_yaml_data(f)
			buildings.append(sorted(list(_get_referenced_buildings(data))))

	assert buildings[0] == buildings[1]
Пример #8
0
def test_build_menu_consistency():
    """
	Check that the same buildings are referenced in both configurations of the build menu.
	"""
    assert len(BuildTab.build_menus) == 2, 'Expected 2 build menu configs'

    buildings = []
    for filename in BuildTab.build_menus:
        with open(os.path.join(ROOT_DIR, filename)) as f:
            data = YamlCache.load_yaml_data(f)
            buildings.append(sorted(list(_get_referenced_buildings(data))))

    assert buildings[0] == buildings[1]
Пример #9
0
    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'))

        if 'metadata' in data:
            # no stats available => empty label
            stats = data['metadata'].get('translation_status', '')
        else:
            # Old scenario syntax version without metadata
            stats = data.get('translation_status', '')
        self.statslabel.text = str(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'))

		if 'metadata' in data:
			# no stats available => empty label
			stats = data['metadata'].get('translation_status', '')
		else:
			# Old scenario syntax version without metadata
			stats = data.get('translation_status', '')
		self.statslabel.text = str(stats)
    def load(self):
        """Load selected scenario and show strings"""
        # 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 _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))
Пример #13
0
 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))