<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from __future__ import division <EOL> from __future__ import absolute_import <EOL> from future . builtins import str <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> try : <EOL> from base64 import encodebytes as _bencode <EOL> except ImportError : <EOL> from base64 import encodestring as _bencode <EOL> from quopri import encodestring as _encodestring <EOL> def _qencode ( s ) : <EOL> enc = _encodestring ( s , quotetabs = True ) <EOL> return enc . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) <EOL> def encode_base64 ( msg ) : <EOL> """<STR_LIT>""" <EOL> orig = msg . get_payload ( ) <EOL> encdata = str ( _bencode ( orig ) , '<STR_LIT:ascii>' ) <EOL> msg . set_payload ( encdata ) <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def encode_quopri ( msg ) : <EOL> """<STR_LIT>""" <EOL> orig = msg . get_payload ( ) <EOL> encdata = _qencode ( orig ) <EOL> msg . set_payload ( encdata ) <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def encode_7or8bit ( msg ) : <EOL> """<STR_LIT>""" <EOL> orig = msg . get_payload ( ) <EOL> if orig is None : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return <EOL> try : <EOL> if isinstance ( orig , str ) : <EOL> orig . encode ( '<STR_LIT:ascii>' ) <EOL> else : <EOL> orig . decode ( '<STR_LIT:ascii>' ) <EOL> except UnicodeError : <EOL> charset = msg . get_charset ( ) <EOL> output_cset = charset and charset . output_charset <EOL> if output_cset and output_cset . lower ( ) . startswith ( '<STR_LIT>' ) : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if not isinstance ( orig , str ) : <EOL> msg . set_payload ( orig . decode ( '<STR_LIT:ascii>' , '<STR_LIT>' ) ) <EOL> def encode_noop ( msg ) : <EOL> """<STR_LIT>""" <EOL> orig = msg . get_payload ( ) <EOL> if not isinstance ( orig , str ) : <EOL> msg . set_payload ( orig . decode ( '<STR_LIT:ascii>' , '<STR_LIT>' ) ) </s>
