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


Python parser.Parser方法代码示例

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


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

示例1: parse_headers

# 需要导入模块: from future.backports.email import parser [as 别名]
# 或者: from future.backports.email.parser import Parser [as 别名]
def parse_headers(fp, _class=HTTPMessage):
    """Parses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    """
    headers = []
    while True:
        line = fp.readline(_MAXLINE + 1)
        if len(line) > _MAXLINE:
            raise LineTooLong("header line")
        headers.append(line)
        if len(headers) > _MAXHEADERS:
            raise HTTPException("got more than %d headers" % _MAXHEADERS)
        if line in (b'\r\n', b'\n', b''):
            break
    hstring = bytes(b'').join(headers).decode('iso-8859-1')
    return email_parser.Parser(_class=_class).parsestr(hstring) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:24,代码来源:client.py

示例2: message_from_string

# 需要导入模块: from future.backports.email import parser [as 别名]
# 或者: from future.backports.email.parser import Parser [as 别名]
def message_from_string(s, *args, **kws):
    """Parse a string into a Message object model.

    Optional _class and strict are passed to the Parser constructor.
    """
    from future.backports.email.parser import Parser
    return Parser(*args, **kws).parsestr(s) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:__init__.py

示例3: message_from_bytes

# 需要导入模块: from future.backports.email import parser [as 别名]
# 或者: from future.backports.email.parser import Parser [as 别名]
def message_from_bytes(s, *args, **kws):
    """Parse a bytes string into a Message object model.

    Optional _class and strict are passed to the Parser constructor.
    """
    from future.backports.email.parser import BytesParser
    return BytesParser(*args, **kws).parsebytes(s) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:__init__.py

示例4: message_from_file

# 需要导入模块: from future.backports.email import parser [as 别名]
# 或者: from future.backports.email.parser import Parser [as 别名]
def message_from_file(fp, *args, **kws):
    """Read a file and parse its contents into a Message object model.

    Optional _class and strict are passed to the Parser constructor.
    """
    from future.backports.email.parser import Parser
    return Parser(*args, **kws).parse(fp) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:__init__.py

示例5: message_from_binary_file

# 需要导入模块: from future.backports.email import parser [as 别名]
# 或者: from future.backports.email.parser import Parser [as 别名]
def message_from_binary_file(fp, *args, **kws):
    """Read a binary file and parse its contents into a Message object model.

    Optional _class and strict are passed to the Parser constructor.
    """
    from future.backports.email.parser import BytesParser
    return BytesParser(*args, **kws).parse(fp) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:__init__.py


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