本文整理汇总了Python中config.Configuration.save方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.save方法的具体用法?Python Configuration.save怎么用?Python Configuration.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_config
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import save [as 别名]
def test_create_config(self):
"""
Tests creation of a blank configuration ensuring that the file is not created on the file system until after the
save() method is called on the configuration object. Also implicitly tests writing blank config files.
"""
conf = Configuration(testconfig, create=True)
if os.path.exists(testconfig):
self.fail("File should not be written until save() is executed")
conf.save()
self.assertTrue(os.path.isfile(testconfig), "File should exist after having been written")
示例2: Solstice
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import save [as 别名]
class Solstice(object):
@staticmethod
def _platform_specific_init():
if platform.system() == 'Windows':
os.environ['SDL_AUDIODRIVER'] = 'dsound'
def __init__(self):
Solstice._platform_specific_init()
self._config = Configuration()
self._translations_init()
self._pygame_init()
self._screen = Screen(self._config, _('Solstice'))
self._control = Control(self)
# TODO: Change data file name (don't use .zip extension)
self._resource_manager = ResourceManager(self, 'data.zip')
self._sound_player = SoundPlayer(self)
self._scenes = {
'logo': LogoScene(self),
'intro': IntroScene(self),
'game': GameScene(self),
'elevator': ElevatorScene(self)
}
# The first parameter is the game 'context'
self._scene_manager = SceneManager(self, 'logo')
def _translations_init(self):
gettext.bindtextdomain('solstice', self._config.locale_path)
gettext.textdomain('solstice')
def _sound_preinit(self):
if self._config.sound or self._config.music:
pygame.mixer.pre_init(22050, -16, 2, 1024)
def _pygame_init(self):
self._sound_preinit()
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.init()
def run(self):
self._scene_manager.run()
def exit(self, exit_code):
self._config.save()
pygame.quit()
sys.exit(exit_code)
@property
def config(self):
return self._config
@property
def screen(self):
return self._screen
@property
def resource_manager(self):
return self._resource_manager
@property
def control(self):
return self._control
@property
def sound_player(self):
return self._sound_player
@property
def scenes(self):
return self._scenes
@property
def scene_manager(self):
return self._scene_manager