本文整理汇总了Python中kivy.config.ConfigParser.sections方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.sections方法的具体用法?Python ConfigParser.sections怎么用?Python ConfigParser.sections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.sections方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_config
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import sections [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
示例2: Backlight_Control
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import sections [as 别名]
# ===========================
# Control The Backlight
# ===========================
def Backlight_Control(light_status):
subproces.call('echo 0 > Light.SATUS')
# ========================
# Load the Defaults
# ========================
config = ConfigParser()
config.read('doorbell.ini')
CODES = ConfigParser()
CODES.read('codes.ini')
CODES_DICT = {s:dict(CODES.items(s)) for s in CODES.sections()}
NUMBERS = ConfigParser()
NUMBERS.read('numbers.ini')
NUMBERS_DICT = {s:dict(NUMBERS.items(s)) for s in NUMBERS.sections()}
LANGUAGES = ConfigParser()
LANGUAGES.read('languages.ini')
LANGUAGES_DICT = {s:dict(LANGUAGES.items(s)) for s in LANGUAGES.sections()}
# ===========================
# Load the Sound Effects
# ===========================
Sound_Click = SoundLoader.load(config.get('Sounds','Sound_Click'))