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