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


Python errors.NonPrintableDefect方法代码示例

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


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

示例1: get_qp_ctext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_qp_ctext(value):
    """ctext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII an NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    """
    ptext, value, _ = _get_ptext_to_endchars(value, '()')
    ptext = WhiteSpaceTerminal(ptext, 'ptext')
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:_header_value_parser.py

示例2: get_dtext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_dtext(value):
    """ dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII an NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    """
    ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')
    ptext = ValueTerminal(ptext, 'ptext')
    if had_qp:
        ptext.defects.append(errors.ObsoleteHeaderDefect(
            "quoted printable found in domain-literal"))
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:_header_value_parser.py

示例3: get_qp_ctext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_qp_ctext(value):
    r"""ctext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    """
    ptext, value, _ = _get_ptext_to_endchars(value, '()')
    ptext = WhiteSpaceTerminal(ptext, 'ptext')
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:18,代码来源:_header_value_parser.py

示例4: get_dtext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_dtext(value):
    r""" dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    """
    ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')
    ptext = ValueTerminal(ptext, 'ptext')
    if had_qp:
        ptext.defects.append(errors.ObsoleteHeaderDefect(
            "quoted printable found in domain-literal"))
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:21,代码来源:_header_value_parser.py

示例5: get_qp_ctext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_qp_ctext(value):
    """ctext = <printable ascii except \ ( )>

    This is not the RFC ctext, since we are handling nested comments in comment
    and unquoting quoted-pairs here.  We allow anything except the '()'
    characters, but if we find any ASCII other than the RFC defined printable
    ASCII, a NonPrintableDefect is added to the token's defects list.  Since
    quoted pairs are converted to their unquoted values, what is returned is
    a 'ptext' token.  In this case it is a WhiteSpaceTerminal, so it's value
    is ' '.

    """
    ptext, value, _ = _get_ptext_to_endchars(value, '()')
    ptext = WhiteSpaceTerminal(ptext, 'ptext')
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:18,代码来源:_header_value_parser.py

示例6: get_dtext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_dtext(value):
    """ dtext = <printable ascii except \ [ ]> / obs-dtext
        obs-dtext = obs-NO-WS-CTL / quoted-pair

    We allow anything except the excluded characters, but if we find any
    ASCII other than the RFC defined printable ASCII, a NonPrintableDefect is
    added to the token's defects list.  Quoted pairs are converted to their
    unquoted values, so what is returned is a ptext token, in this case a
    ValueTerminal.  If there were quoted-printables, an ObsoleteHeaderDefect is
    added to the returned token's defect list.

    """
    ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')
    ptext = ValueTerminal(ptext, 'ptext')
    if had_qp:
        ptext.defects.append(errors.ObsoleteHeaderDefect(
            "quoted printable found in domain-literal"))
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:21,代码来源:_header_value_parser.py

示例7: _validate_xtext

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def _validate_xtext(xtext):
    """If input token contains ASCII non-printables, register a defect."""

    non_printables = _non_printable_finder(xtext)
    if non_printables:
        xtext.defects.append(errors.NonPrintableDefect(non_printables))
    if utils._has_surrogates(xtext):
        xtext.defects.append(errors.UndecodableBytesDefect(
            "Non-ASCII characters found in header token")) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:_header_value_parser.py

示例8: get_qcontent

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def get_qcontent(value):
    """qcontent = qtext / quoted-pair

    We allow anything except the DQUOTE character, but if we find any ASCII
    other than the RFC defined printable ASCII an NonPrintableDefect is
    added to the token's defects list.  Any quoted pairs are converted to their
    unquoted values, so what is returned is a 'ptext' token.  In this case it
    is a ValueTerminal.

    """
    ptext, value, _ = _get_ptext_to_endchars(value, '"')
    ptext = ValueTerminal(ptext, 'ptext')
    _validate_xtext(ptext)
    return ptext, value 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:_header_value_parser.py

示例9: test_get_encoded_word_non_printable_defect

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_encoded_word_non_printable_defect(self):
        self._test_get_x(parser.get_encoded_word,
                         '=?us-ascii?q?first\x02second?=',
                         'first\x02second',
                         'first\x02second',
                         [errors.NonPrintableDefect],
                         '') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test__header_value_parser.py

示例10: test_get_qcontent_non_printables

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_qcontent_non_printables(self):
        ptext = self._test_get_x(parser.get_qcontent,
                                'foo\x00fg"', 'foo\x00fg', 'foo\x00fg',
                                [errors.NonPrintableDefect], '"')
        self.assertEqual(ptext.defects[0].non_printables[0], '\x00')

    # get_atext 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test__header_value_parser.py

示例11: test_get_atext_non_printables

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_atext_non_printables(self):
        atext = self._test_get_x(parser.get_atext,
                                'foo\x00bar(', 'foo\x00bar', 'foo\x00bar',
                                [errors.NonPrintableDefect], '(')
        self.assertEqual(atext.defects[0].non_printables[0], '\x00')

    # get_bare_quoted_string 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test__header_value_parser.py

示例12: test_get_bare_quoted_string_non_printables

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_bare_quoted_string_non_printables(self):
        self._test_get_x(parser.get_bare_quoted_string,
             '"a\x01a"', '"a\x01a"', 'a\x01a',
             [errors.NonPrintableDefect], '') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test__header_value_parser.py

示例13: test_get_comment_non_printable

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_comment_non_printable(self):
        self._test_get_x(parser.get_comment,
            '(foo\x7Fbar)', '(foo\x7Fbar)', ' ',
            [errors.NonPrintableDefect], '', ['foo\x7Fbar']) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test__header_value_parser.py

示例14: test_get_cfws_non_printable_in_comment

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_cfws_non_printable_in_comment(self):
        cfws = self._test_get_x(parser.get_cfws,
            '(foo \x07) "test"', '(foo \x07) ', ' ',
            [errors.NonPrintableDefect], '"test"', ['foo \x07'])
        self.assertEqual(cfws[0].content, 'foo \x07') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test__header_value_parser.py

示例15: test_get_quoted_string_non_printable_in_qcontent

# 需要导入模块: from email import errors [as 别名]
# 或者: from email.errors import NonPrintableDefect [as 别名]
def test_get_quoted_string_non_printable_in_qcontent(self):
        qs = self._test_get_x(parser.get_quoted_string,
            ' (a) "a\x0B"', ' (a) "a\x0B"', ' a\x0B',
                [errors.NonPrintableDefect], '')
        self.assertEqual(qs[0].comments, ['a'])
        self.assertEqual(qs.content, 'a\x0B')
        self.assertEqual(qs.quoted_value, ' "a\x0B"') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test__header_value_parser.py


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