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


Python errors.InvalidHeaderError方法代码示例

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


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

示例1: get_section

# 需要导入模块: from future.backports.email import errors [as 别名]
# 或者: from future.backports.email.errors import InvalidHeaderError [as 别名]
def get_section(value):
    """ '*' digits

    The formal BNF is more complicated because leading 0s are not allowed.  We
    check for that and add a defect.  We also assume no CFWS is allowed between
    the '*' and the digits, though the RFC is not crystal clear on that.
    The caller should already have dealt with leading CFWS.

    """
    section = Section()
    if not value or value[0] != '*':
        raise errors.HeaderParseError("Expected section but found {}".format(
                                        value))
    section.append(ValueTerminal('*', 'section-marker'))
    value = value[1:]
    if not value or not value[0].isdigit():
        raise errors.HeaderParseError("Expected section number but "
                                      "found {}".format(value))
    digits = ''
    while value and value[0].isdigit():
        digits += value[0]
        value = value[1:]
    if digits[0] == '0' and digits != '0':
        section.defects.append(errors.InvalidHeaderError("section number"
            "has an invalid leading 0"))
    section.number = int(digits)
    section.append(ValueTerminal(digits, 'digits'))
    return section, value 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:_header_value_parser.py


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