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


Python ConfigParser.getfloat方法代码示例

本文整理汇总了Python中kivy.config.ConfigParser.getfloat方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.getfloat方法的具体用法?Python ConfigParser.getfloat怎么用?Python ConfigParser.getfloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.config.ConfigParser的用法示例。


在下文中一共展示了ConfigParser.getfloat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UserPrefs

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getfloat [as 别名]

#.........这里部分代码省略.........
        '''
        self.config.adddefaultsection(section)

    def get_pref_bool(self, section, option, default=None):
        '''
        Retrieve a preferences value as a bool. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default bool
        :return bool preference value
        '''
        try:
            return self.config.getboolean(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_float(self, section, option, default=None):
        '''
        Retrieve a preferences value as a float. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default float
        :return float preference value
        '''
        try:
            return self.config.getfloat(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_int(self, section, option, default=None):
        '''
        Retrieve a preferences value as an int. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return int preference value
        '''
        try:
            return self.config.getint(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref(self, section, option, default=None):
        '''
        Retrieve a preferences value as a string. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return string preference value
        '''
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:70,代码来源:prefs.py

示例2: update_program

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getfloat [as 别名]
    def update_program(self):
        """Проверяет наличие обновлений на сервере github,com.
        Проверяестя версия программы, версии плагинов, наличие измененных
        программых файлов."""

        if platform != "android":
            print("Проверка обновлений:")
            print("------------------------------------")

        temp_path = "{}/Data/temp".format(core.prog_path)

        if not os.path.exists(temp_path):
            os.mkdir(temp_path)

        update_file = urllib.urlopen(
            "https://github.com/HeaTTheatR/HeaTDV4A/raw/master/"
            "Data/uploadinfo.ini").read()
        open("{}/uploadinfo.ini".format(temp_path), "w").write(
            update_file)

        config_update = ConfigParser()
        config_update.read("{}/uploadinfo.ini".format(temp_path))

        info_list_update = []

        new_version_program = \
            config_update.getfloat("info_update", "new_version_program")
        updated_files_program = \
            eval(config_update.get("info_update", "updated_files_program"))
        dict_official_plugins_program = \
            config_update.items("plugin_update")
        official_plugins_program = dict(dict_official_plugins_program)

        install_user_plugins = self.started_plugins
        current_version_program = __version__

        if platform != "android":
            print("Проверка версии программы ...")
            print("Проверка актуальности плагинов ...")

        for plugin in install_user_plugins.keys():
            try:
                info_official_plugin = eval(official_plugins_program[plugin])
                if info_official_plugin[plugin]['plugin-version'] > \
                        install_user_plugins[plugin]['plugin-version']:
                    info_list_update.append(info_official_plugin)

                    if platform != "android":
                        print("Плагин '{}' обновился до версии '{}'!".format(
                            plugin, info_official_plugin[plugin][
                                'plugin-version']))
            except KeyError:
                continue

        if platform != "android":
            print("Проверка обновлений завершена ...")
            print("------------------------------------")
            print()

        if len(info_list_update) or new_version_program > \
                current_version_program:
            self.update = True

            if platform != "android":
                print("Доступны обновления!")
                print("------------------------------------")
                print()
        else:
            if platform != "android":
                print("Обновлений нет!")
                print("------------------------------------")
                print()
开发者ID:HeaTTheatR,项目名称:HeaTDV4A,代码行数:74,代码来源:program.py

示例3: UserPrefs

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getfloat [as 别名]

#.........这里部分代码省略.........
                    for id, channel in content_dict["gauge_settings"].iteritems():
                        self._prefs_dict["gauge_settings"][id] = channel

        except Exception:
            pass

    def get_pref_bool(self, section, option, default=None):
        '''
        Retrieve a preferences value as a bool. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default bool
        :return bool preference value
        '''
        try:
            return self.config.getboolean(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_float(self, section, option, default=None):
        '''
        Retrieve a preferences value as a float. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default float
        :return float preference value
        '''
        try:
            return self.config.getfloat(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_int(self, section, option, default=None):
        '''
        Retrieve a preferences value as an int. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return int preference value
        '''
        try:
            return self.config.getint(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref(self, section, option, default=None):
        '''
        Retrieve a preferences value as a string. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return string preference value
        '''
        try:
            return self.config.get(section, option)
        except (NoOptionError, ValueError):
            return default

    def set_pref(self, section, option, value):
        '''
        Set a preference value
        :param section the configuration section for the preference
        :type string
        :param option the option for the section
        :type string
        :param value the preference value to set
        :type value user specified
        '''
        self.config.set(section, option, value)
        self.config.write()

    def to_json(self):
        '''
        Serialize preferences to json
        '''
        data = {'range_alerts': {}, 'gauge_settings':{}}

        for name, range_alert in self._prefs_dict["range_alerts"].iteritems():
            data["range_alerts"][name] = range_alert.to_dict()

        for id, channel in self._prefs_dict["gauge_settings"].iteritems():
            data["gauge_settings"][id] = channel

        return json.dumps(data)
开发者ID:ddimensia,项目名称:RaceCapture_App,代码行数:104,代码来源:prefs.py


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