Python quopri.encode() Examples

The following are 30 code examples of quopri.encode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module quopri , or try the search function .
Example #1
Source File: mimetools.py    From BinderFilter with MIT License 6 votes vote down vote up
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 
Example #2
Source File: mimetools.py    From meddle with MIT License 6 votes vote down vote up
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 
Example #3
Source File: mimetools.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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 
Example #4
Source File: mimetools.py    From Computable with MIT License 6 votes vote down vote up
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 
Example #5
Source File: mimetools.py    From pmatic with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #6
Source File: mimetools.py    From GDCTSCP with GNU Affero General Public License v3.0 6 votes vote down vote up
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 
Example #7
Source File: mimetools.py    From oss-ftp with MIT License 6 votes vote down vote up
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 
Example #8
Source File: quopri_codec.py    From ImageFusion with MIT License 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #9
Source File: quopri_codec.py    From scylla with Apache License 2.0 5 votes vote down vote up
def encode(self, input, errors='strict'):
        return quopri_encode(input, errors) 
Example #10
Source File: quopri_codec.py    From scylla with Apache License 2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0] 
Example #11
Source File: quopri_codec.py    From scylla with Apache License 2.0 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #12
Source File: quopri_codec.py    From telegram-robot-rss with Mozilla Public License 2.0 5 votes vote down vote up
def quopri_encode(input, errors='strict'):
    """Encode the input, returning a tuple (output object, length consumed).

    errors defines the error handling to apply. It defaults to
    'strict' handling which is the only currently supported
    error handling for this codec.

    """
    assert errors == 'strict'
    # using str() because of cStringIO's Unicode undesired Unicode behavior.
    f = StringIO(str(input))
    g = StringIO()
    quopri.encode(f, g, quotetabs=True)
    output = g.getvalue()
    return (output, len(input)) 
Example #13
Source File: quopri_codec.py    From ImageFusion with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0] 
Example #14
Source File: quopri_codec.py    From python with Apache License 2.0 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #15
Source File: quopri_codec.py    From ImageFusion with MIT License 5 votes vote down vote up
def quopri_encode(input, errors='strict'):
    """Encode the input, returning a tuple (output object, length consumed).

    errors defines the error handling to apply. It defaults to
    'strict' handling which is the only currently supported
    error handling for this codec.

    """
    assert errors == 'strict'
    # using str() because of cStringIO's Unicode undesired Unicode behavior.
    f = StringIO(str(input))
    g = StringIO()
    quopri.encode(f, g, quotetabs=True)
    output = g.getvalue()
    return (output, len(input)) 
Example #16
Source File: quopri_codec.py    From ImageFusion with MIT License 5 votes vote down vote up
def encode(self, input,errors='strict'):
        return quopri_encode(input,errors) 
Example #17
Source File: quopri_codec.py    From ImageFusion with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0] 
Example #18
Source File: quopri_codec.py    From telegram-robot-rss with Mozilla Public License 2.0 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #19
Source File: quopri_codec.py    From scylla with Apache License 2.0 5 votes vote down vote up
def quopri_encode(input, errors='strict'):
    assert errors == 'strict'
    f = BytesIO(input)
    g = BytesIO()
    quopri.encode(f, g, quotetabs=True)
    return (g.getvalue(), len(input)) 
Example #20
Source File: quopri_codec.py    From Imogen with MIT License 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #21
Source File: quopri_codec.py    From Imogen with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0] 
Example #22
Source File: quopri_codec.py    From Imogen with MIT License 5 votes vote down vote up
def encode(self, input, errors='strict'):
        return quopri_encode(input, errors) 
Example #23
Source File: quopri_codec.py    From Imogen with MIT License 5 votes vote down vote up
def quopri_encode(input, errors='strict'):
    assert errors == 'strict'
    f = BytesIO(input)
    g = BytesIO()
    quopri.encode(f, g, quotetabs=True)
    return (g.getvalue(), len(input)) 
Example #24
Source File: test_quopri.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_encode(self):
        for p, e in self.STRINGS:
            infp = io.BytesIO(p)
            outfp = io.BytesIO()
            quopri.encode(infp, outfp, quotetabs=False)
            self.assertEqual(outfp.getvalue(), e) 
Example #25
Source File: quopri_codec.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #26
Source File: quopri_codec.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0] 
Example #27
Source File: quopri_codec.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, errors='strict'):
        return quopri_encode(input, errors) 
Example #28
Source File: quopri_codec.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def quopri_encode(input, errors='strict'):
    assert errors == 'strict'
    f = BytesIO(input)
    g = BytesIO()
    quopri.encode(f, g, quotetabs=True)
    return (g.getvalue(), len(input)) 
Example #29
Source File: quopri_codec.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
Example #30
Source File: quopri_codec.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return quopri_encode(input, self.errors)[0]