本文整理汇总了Python中kivy.config.ConfigParser.name方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.name方法的具体用法?Python ConfigParser.name怎么用?Python ConfigParser.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_config
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import name [as 别名]
def load_config(self):
'''(internal) This function is used for returning a ConfigParser with
the application configuration. It's doing 3 things:
#. Creating an instance of a ConfigParser
#. Loading the default configuration by calling
:meth:`build_config`, then
#. If it exists, it loads the application configuration file,
otherwise it creates one.
:return:
:class:`~kivy.config.ConfigParser` instance
'''
try:
config = ConfigParser.get_configparser('app')
except KeyError:
config = None
if config is None:
config = ConfigParser(name='app')
self.config = config
self.build_config(config)
# if no sections are created, that's mean the user don't have
# configuration.
if len(config.sections()) == 0:
return
# ok, the user have some sections, read the default file if exist
# or write it !
filename = self.get_application_config()
if filename is None:
return config
Logger.debug('App: Loading configuration <{0}>'.format(filename))
if exists(filename):
try:
config.read(filename)
except:
Logger.error('App: Corrupted config file, ignored.')
config.name = ''
try:
config = ConfigParser.get_configparser('app')
except KeyError:
config = None
if config is None:
config = ConfigParser(name='app')
self.config = config
self.build_config(config)
pass
else:
Logger.debug('App: First configuration, create <{0}>'.format(
filename))
config.filename = filename
config.write()
return config