當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。