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


Python parser.FeedParser方法代码示例

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


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

示例1: check_dist_requires_python

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def check_dist_requires_python(dist):
    metadata = get_metadata(dist)
    feed_parser = FeedParser()
    feed_parser.feed(metadata)
    pkg_info_dict = feed_parser.close()
    requires_python = pkg_info_dict.get('Requires-Python')
    try:
        if not check_requires_python(requires_python):
            raise exceptions.UnsupportedPythonVersion(
                "%s requires Python '%s' but the running Python is %s" % (
                    dist.project_name,
                    requires_python,
                    '.'.join(map(str, sys.version_info[:3])),)
            )
    except specifiers.InvalidSpecifier as e:
        logger.warning(
            "Package %s has an invalid Requires-Python entry %s - %s" % (
                dist.project_name, requires_python, e))
        return 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:packaging.py

示例2: get_metadata

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def get_metadata(dist):
    # type: (Distribution) -> Message
    """
    :raises NoneMetadataError: if the distribution reports `has_metadata()`
        True but `get_metadata()` returns None.
    """
    metadata_name = 'METADATA'
    if (isinstance(dist, pkg_resources.DistInfoDistribution) and
            dist.has_metadata(metadata_name)):
        metadata = dist.get_metadata(metadata_name)
    elif dist.has_metadata('PKG-INFO'):
        metadata_name = 'PKG-INFO'
        metadata = dist.get_metadata(metadata_name)
    else:
        logger.warning("No metadata found in %s", display_path(dist.location))
        metadata = ''

    if metadata is None:
        raise NoneMetadataError(dist, metadata_name)

    feed_parser = FeedParser()
    # The following line errors out if with a "NoneType" TypeError if
    # passed metadata=None.
    feed_parser.feed(metadata)
    return feed_parser.close() 
开发者ID:pantsbuild,项目名称:pex,代码行数:27,代码来源:packaging.py

示例3: get_dist_metadata

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def get_dist_metadata(dist):
    import pkg_resources
    from email.parser import FeedParser

    if isinstance(dist, pkg_resources.DistInfoDistribution) and dist.has_metadata(
        "METADATA"
    ):
        metadata = dist.get_metadata("METADATA")
    elif dist.has_metadata("PKG-INFO"):
        metadata = dist.get_metadata("PKG-INFO")
    else:
        metadata = ""

    feed_parser = FeedParser()
    feed_parser.feed(metadata)
    return feed_parser.close() 
开发者ID:pypa,项目名称:pipenv,代码行数:18,代码来源:utils.py

示例4: pkg_info

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def pkg_info(self):
        p = FeedParser()
        data = self.egg_info_data('PKG-INFO')
        if not data:
            logger.warning(
                'No PKG-INFO file found in %s',
                display_path(self.egg_info_path('PKG-INFO')),
            )
        p.feed(data or '')
        return p.close() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:req_install.py

示例5: _deserialize_response

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def _deserialize_response(self, payload):
    """Convert string into httplib2 response and content.

    Args:
      payload: string, headers and body as a string.

    Returns:
      A pair (resp, content), such as would be returned from httplib2.request.
    """
    # Strip off the status line
    status_line, payload = payload.split('\n', 1)
    protocol, status, reason = status_line.split(' ', 2)

    # Parse the rest of the response
    parser = FeedParser()
    parser.feed(payload)
    msg = parser.close()
    msg['status'] = status

    # Create httplib2.Response from the parsed headers.
    resp = httplib2.Response(msg)
    resp.reason = reason
    resp.version = int(protocol.split('/', 1)[1].replace('.', ''))

    content = payload.split('\r\n\r\n', 1)[1]

    return resp, content 
开发者ID:splunk,项目名称:splunk-ref-pas-code,代码行数:29,代码来源:http.py

示例6: pkg_info

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def pkg_info(self):
        p = FeedParser()
        data = self.egg_info_data('PKG-INFO')
        if not data:
            logger.warn('No PKG-INFO file found in %s' % display_path(self.egg_info_path('PKG-INFO')))
        p.feed(data or '')
        return p.close() 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:req.py

示例7: get_metadata

# 需要导入模块: from email import parser [as 别名]
# 或者: from email.parser import FeedParser [as 别名]
def get_metadata(dist):
    # type: (Distribution) -> Message
    if (isinstance(dist, pkg_resources.DistInfoDistribution) and
            dist.has_metadata('METADATA')):
        metadata = dist.get_metadata('METADATA')
    elif dist.has_metadata('PKG-INFO'):
        metadata = dist.get_metadata('PKG-INFO')
    else:
        logger.warning("No metadata found in %s", display_path(dist.location))
        metadata = ''

    feed_parser = FeedParser()
    feed_parser.feed(metadata)
    return feed_parser.close() 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:16,代码来源:packaging.py


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