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


Python ConfigParser.read_string方法代码示例

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


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

示例1: extract_metadata

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import read_string [as 别名]
    def extract_metadata(self):
        """Return info from the metadata.txt inside the zip file"""
        opened_zip_file = zipfile.ZipFile(self.filename, 'r')
        expected = [f.filename for f in opened_zip_file.filelist if f.filename.endswith('metadata.txt')][0]
        metadata = ConfigParser()
        try: # Py2
            metadata.readfp(opened_zip_file.open(expected))
        except TypeError: # Py3
            md = opened_zip_file.open(expected).read()
            metadata.read_string(md.decode('utf-8'))

        result = {}

        def get_option(section, option, default=''):
            try:
                return metadata.get(section, option)
            except NoOptionError:
                return default

        result['name'] = get_option('general', 'name')
        result['about'] = get_option('general', 'about')
        result['download_url'] = get_option('general', 'about')
        result['version'] = get_option('general', 'version')
        result['description'] = get_option('general', 'description')
        result['qgis_minimum_version'] = get_option('general', 'qgisMinimumVersion')
        result['qgis_maximum_version'] = get_option('general', 'qgisMaximumVersion', '')
        result['author_name'] = get_option('general', 'author').replace('&', '&')
        result['homepage'] = get_option('general', 'homepage', '')
        result['tracker'] = get_option('general', 'tracker', '')
        result['repository'] = get_option('general', 'repository', '')
        result['tags'] = get_option('general', 'tags', '')
        result['changelog'] = get_option('general', 'changelog')
        result['experimental'] = get_option('general', 'experimental', False)
        result['deprecated'] = get_option('general', 'experimental', False)
        return result
开发者ID:boundlessgeo,项目名称:qgis-plugin-repos,代码行数:37,代码来源:update_index.py


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