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


Python uu.encode方法代码示例

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


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

示例1: encode

# 需要导入模块: import uu [as 别名]
# 或者: from uu import encode [as 别名]
def encode(input, output, encoding):
    """Encode common content-transfer-encodings (base64, quopri, uuencode)."""
    if encoding == 'base64':
        import base64
        return base64.encode(input, output)
    if encoding == 'quoted-printable':
        import quopri
        return quopri.encode(input, output, 0)
    if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'):
        import uu
        return uu.encode(input, output)
    if encoding in ('7bit', '8bit'):
        return output.write(input.read())
    if encoding in encodetab:
        pipethrough(input, encodetab[encoding], output)
    else:
        raise ValueError, \
              'unknown Content-Transfer-Encoding: %s' % encoding

# The following is no longer used for standard encodings

# XXX This requires that uudecode and mmencode are in $PATH 
开发者ID:glmcdona,项目名称:meddle,代码行数:24,代码来源:mimetools.py

示例2: test_encode

# 需要导入模块: import uu [as 别名]
# 或者: from uu import encode [as 别名]
def test_encode(self):
        with open(self.tmpin, 'wb') as fin:
            fin.write(plaintext)

        with open(self.tmpin, 'rb') as fin:
            with open(self.tmpout, 'w') as fout:
                uu.encode(fin, fout, self.tmpin, mode=0o644)

        with open(self.tmpout, 'r') as fout:
            s = fout.read()
        self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin))

        # in_file and out_file as filenames
        uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644)
        with open(self.tmpout, 'r') as fout:
            s = fout.read()
        self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_uu.py

示例3: test_newlines_escaped

# 需要导入模块: import uu [as 别名]
# 或者: from uu import encode [as 别名]
def test_newlines_escaped(self):
        # Test newlines are escaped with uu.encode
        inp = io.BytesIO(plaintext)
        out = io.BytesIO()
        filename = "test.txt\n\roverflow.txt"
        safefilename = b"test.txt\\n\\roverflow.txt"
        uu.encode(inp, out, filename)
        self.assertIn(safefilename, out.getvalue()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_uu.py

示例4: test_encode

# 需要导入模块: import uu [as 别名]
# 或者: from uu import encode [as 别名]
def test_encode(self):
        inp = cStringIO.StringIO(plaintext)
        out = cStringIO.StringIO()
        uu.encode(inp, out, "t1")
        self.assertEqual(out.getvalue(), encodedtextwrapped % (0666, "t1"))
        inp = cStringIO.StringIO(plaintext)
        out = cStringIO.StringIO()
        uu.encode(inp, out, "t1", 0644)
        self.assertEqual(out.getvalue(), encodedtextwrapped % (0644, "t1")) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:11,代码来源:test_uu.py

示例5: test_encode

# 需要导入模块: import uu [as 别名]
# 或者: from uu import encode [as 别名]
def test_encode(self):
        inp = io.BytesIO(plaintext)
        out = io.BytesIO()
        uu.encode(inp, out, "t1")
        self.assertEqual(out.getvalue(), encodedtextwrapped(0o666, "t1"))
        inp = io.BytesIO(plaintext)
        out = io.BytesIO()
        uu.encode(inp, out, "t1", 0o644)
        self.assertEqual(out.getvalue(), encodedtextwrapped(0o644, "t1")) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_uu.py


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