当前位置: 首页>>代码示例>>Python>>正文


Python ConfigParser.sections方法代码示例

本文整理汇总了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
开发者ID:AndiEcker,项目名称:kivy,代码行数:54,代码来源:app.py

示例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')) 
开发者ID:lmarton,项目名称:RaspiBell,代码行数:33,代码来源:DoorBell.py


注:本文中的kivy.config.ConfigParser.sections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。