本文整理汇总了Python中horizons.scenario.ScenarioEventHandler.get_description_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python ScenarioEventHandler.get_description_from_file方法的具体用法?Python ScenarioEventHandler.get_description_from_file怎么用?Python ScenarioEventHandler.get_description_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.scenario.ScenarioEventHandler
的用法示例。
在下文中一共展示了ScenarioEventHandler.get_description_from_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_infos
# 需要导入模块: from horizons.scenario import ScenarioEventHandler [as 别名]
# 或者: from horizons.scenario.ScenarioEventHandler import get_description_from_file [as 别名]
def _update_infos():
"""Fill in infos of selected scenario to label"""
try:
difficulty = ScenarioEventHandler.get_difficulty_from_file( self.__get_selected_map() )
desc = ScenarioEventHandler.get_description_from_file( self.__get_selected_map() )
author = ScenarioEventHandler.get_author_from_file( self.__get_selected_map() )
except InvalidScenarioFileFormat, e:
self.__show_invalid_scenario_file_popup(e)
return
示例2: _update_infos
# 需要导入模块: from horizons.scenario import ScenarioEventHandler [as 别名]
# 或者: from horizons.scenario.ScenarioEventHandler import get_description_from_file [as 别名]
def _update_infos():
"""Fill in infos of selected scenario to label"""
try:
difficulty = ScenarioEventHandler.get_difficulty_from_file( self._get_selected_map() )
desc = ScenarioEventHandler.get_description_from_file( self._get_selected_map() )
author = ScenarioEventHandler.get_author_from_file( self._get_selected_map() )
except InvalidScenarioFileFormat as e:
self._show_invalid_scenario_file_popup(e)
return
self.current.findChild(name="map_difficulty").text = \
_("Difficulty: {difficulty}").format(difficulty=difficulty) #xgettext:python-format
self.current.findChild(name="map_author").text = \
_("Author: {author}").format(author=author) #xgettext:python-format
self.current.findChild(name="map_desc").text = \
_("Description: {desc}").format(desc=desc) #xgettext:python-format
示例3: _update_infos
# 需要导入模块: from horizons.scenario import ScenarioEventHandler [as 别名]
# 或者: from horizons.scenario.ScenarioEventHandler import get_description_from_file [as 别名]
#.........这里部分代码省略.........
#if selected map's file ends with .yaml then get current locale
#to remove locale postfix from selected_map's name
else:
#get current locale to split current map file name
current_locale = yamlcache.YamlCache.get_file(self._get_selected_map(), \
game_data=True)['locale']
new_map_name = self._get_selected_map()[:self._get_selected_map().\
find('_' + current_locale)] + '_' + \
this_locale + '.' + \
SavegameManager.scenario_extension
return new_map_name
cur_selected_language = lang_list.selected_item
selectable_languages = []
#show only selectable languages
for i in find_available_languages().keys():
if os.path.exists(_find_map_filename(i)):
selectable_languages.append(LANGUAGENAMES[i])
selectable_languages.sort()
lang_list.items = selectable_languages
if cur_selected_language in lang_list.items:
lang_list.selected = lang_list.items.index(cur_selected_language)
else:
lang_list.selected = 0
def _update_translation_infos(new_map_name):
"""Fill in translation infos of selected scenario to translation label.
It gets translation_status from new_map_file. If there is no attribute
like translation_status then selected locale is the original locale of
the selected scenario. In this case, hide translation_status_label.
If there are fuzzy translations, show them as untranslated.
This function also sets scenario map name using locale.
(e.g. tutorial -> tutorial_en.yaml)"""
translation_status_label = self.current.findChild(name="translation_status")
try:
#get translation status
translation_status_message = yamlcache.YamlCache.get_file(new_map_name, \
game_data=True)['translation_status']
#find integers in translation_levels string
translation_levels = [int(x) for x in re.findall(r'\d+', translation_status_message)]
#if translation_levels' len is 3 it shows us there are fuzzy ones
#show them as untranslated
if len(translation_levels) == 3:
translation_levels[2] += translation_levels[1]
#if everything is translated then set untranslated count as 0
if len(translation_levels) == 1:
translation_levels.append(0)
translation_status_label.text = _("Translation status:") + '\n' + \
_("{translated} translated messages, {untranslated} untranslated messages")\
.format(translated=translation_levels[0], \
untranslated=translation_levels[-1])
#if selected language is english then don't show translation status
translation_status_label.show()
#if there is no translation_status then hide it
except KeyError:
translation_status_label.hide()
self.current.files[ self.active_right_side.collectData('maplist') ] = new_map_name
#Add locale postfix to fix scenario file
try:
_update_translation_infos(_find_map_filename())
#if there is no scenario with selected locale then select system's default
except IOError:
default_locale = ""
_default_locale, default_encoding = locale.getdefaultlocale()
try:
default_locale = _default_locale.split('_')[0]
except:
# If default locale could not be detected use 'EN' as fallback
default_locale = "en"
#check if default_locale is in list
if LANGUAGENAMES[default_locale] in lang_list.items:
lang_list.selected = lang_list.items.index(LANGUAGENAMES[default_locale])
#if default locale is not in list then select first one
else:
lang_list.selected = 0
_update_infos()
try:
difficulty = ScenarioEventHandler.get_difficulty_from_file( self._get_selected_map() )
desc = ScenarioEventHandler.get_description_from_file( self._get_selected_map() )
author = ScenarioEventHandler.get_author_from_file( self._get_selected_map() )
except InvalidScenarioFileFormat as e:
self._show_invalid_scenario_file_popup(e)
return
self.current.findChild(name="uni_map_difficulty").text = \
_("Difficulty: {difficulty}").format(difficulty=difficulty) #xgettext:python-format
self.current.findChild(name="uni_map_author").text = \
_("Author: {author}").format(author=author) #xgettext:python-format
self.current.findChild(name="uni_map_desc").text = \
_("Description: {desc}").format(desc=desc) #xgettext:python-format