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


Python uu.Error方法代码示例

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


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

示例1: test_truncatedinput

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_truncatedinput(self):
        inp = cStringIO.StringIO("begin 644 t1\n" + encodedtext)
        out = cStringIO.StringIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception raised")
        except uu.Error, e:
            self.assertEqual(str(e), "Truncated input file") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_uu.py

示例2: test_missingbegin

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_missingbegin(self):
        inp = cStringIO.StringIO("")
        out = cStringIO.StringIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception raised")
        except uu.Error, e:
            self.assertEqual(str(e), "No valid begin line found in input file") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_uu.py

示例3: test_decodetwice

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_decodetwice(self):
        # Verify that decode() will refuse to overwrite an existing file
        with open(self.tmpin, 'wb') as f:
            f.write(encodedtextwrapped % (0o644, self.tmpout))
        with open(self.tmpin, 'r') as f:
            uu.decode(f)

        with open(self.tmpin, 'r') as f:
            self.assertRaises(uu.Error, uu.decode, f) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_uu.py

示例4: test_decodetwice

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_decodetwice(self):
        # Verify that decode() will refuse to overwrite an existing file
        f = None
        try:
            f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout))

            f = open(self.tmpin, 'r')
            uu.decode(f)
            f.close()

            f = open(self.tmpin, 'r')
            self.assertRaises(uu.Error, uu.decode, f)
            f.close()
        finally:
            self._kill(f) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:17,代码来源:test_uu.py

示例5: get_decoded_payload

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def get_decoded_payload(self):
        """
        Similar to get_payload(decode=True), but:

        * decoding failures are logged as warnings (instead of being
          completely silent);
        * if the message is a multipart one, the payload of its first
          part is extracted (with `.get_decoded_payload()`, recursively)
          and returned instead of `None`.
        """
        # copied from Py2.7's email.message.Message.get_payload() and adjusted
        payload = self._payload
        if self.is_multipart():
            first_part = payload[0]
            assert isinstance(first_part, self.__class__)
            return first_part.get_decoded_payload()
        cte = self.get('content-transfer-encoding', '').lower()
        if cte == 'quoted-printable':
            payload = quopri.decodestring(payload)
        elif cte == 'base64':
            if payload:
                try:
                    payload = base64.decodestring(payload)
                except binascii.Error:
                    LOGGER.warning('Could not decode the payload using base64'
                                   ' => not decoding')
                    LOGGER.debug('The payload: %r', payload)
        elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
            sfp = StringIO()
            try:
                uu.decode(StringIO(payload + '\n'), sfp, quiet=True)
                payload = sfp.getvalue()
            except uu.Error:
                LOGGER.warning('Could not decode the payload using %s'
                               ' => not decoding', cte)
                LOGGER.debug('The payload: %r', payload)
        elif cte not in ('', '7bit', '8bit', 'binary'):
            LOGGER.warning('Unsupported content-transfer-encoding: %s'
                           ' => not decoding', cte)
            LOGGER.debug('The payload: %r', payload)
        return payload 
开发者ID:CERT-Polska,项目名称:n6,代码行数:43,代码来源:email_message.py

示例6: test_truncatedinput

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_truncatedinput(self):
        inp = io.BytesIO(b"begin 644 t1\n" + encodedtext)
        out = io.BytesIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception raised")
        except uu.Error as e:
            self.assertEqual(str(e), "Truncated input file") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_uu.py

示例7: test_missingbegin

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_missingbegin(self):
        inp = io.BytesIO(b"")
        out = io.BytesIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception raised")
        except uu.Error as e:
            self.assertEqual(str(e), "No valid begin line found in input file") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_uu.py

示例8: test_decodetwice

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_decodetwice(self):
        # Verify that decode() will refuse to overwrite an existing file
        f = None
        try:
            f = io.BytesIO(encodedtextwrapped(0o644, self.tmpout))

            f = open(self.tmpin, 'rb')
            uu.decode(f)
            f.close()

            f = open(self.tmpin, 'rb')
            self.assertRaises(uu.Error, uu.decode, f)
            f.close()
        finally:
            self._kill(f) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_uu.py

示例9: test_truncatedinput

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_truncatedinput(self):
        inp = cStringIO.StringIO("begin 644 t1\n" + encodedtext)
        out = cStringIO.StringIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception thrown")
        except uu.Error, e:
            self.assertEqual(str(e), "Truncated input file") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:10,代码来源:test_uu.py

示例10: test_missingbegin

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_missingbegin(self):
        inp = cStringIO.StringIO("")
        out = cStringIO.StringIO()
        try:
            uu.decode(inp, out)
            self.fail("No exception thrown")
        except uu.Error, e:
            self.assertEqual(str(e), "No valid begin line found in input file") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:10,代码来源:test_uu.py

示例11: test_decodetwice

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def test_decodetwice(self):
        # Verify that decode() will refuse to overwrite an existing file
        try:
            f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout))

            f = open(self.tmpin, 'rb')
            uu.decode(f)
            f.close()

            f = open(self.tmpin, 'rb')
            self.assertRaises(uu.Error, uu.decode, f)
            f.close()
        finally:
            self._kill(f) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:test_uu.py

示例12: check_uu

# 需要导入模块: import uu [as 别名]
# 或者: from uu import Error [as 别名]
def check_uu(msg, data):
    assert msg._payload.encode() != data, "Payload has not been transformed"

    outfile = BytesIO()
    try:
        uu.decode(BytesIO(msg._payload.encode()), outfile)
        payload = outfile.getvalue()
    except uu.Error:
        assert False, "Payload could not be decoded"
    assert payload == data, "Decoded payload does not match input data"

    assert INBOXEN_ENCODING_ERROR_HEADER_NAME not in msg.keys(), "Unexpected error header" 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:14,代码来源:tests.py


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