<s> """<STR_LIT>""" <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> import base64 <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 _bencode ( s ) : <EOL> if not s : <EOL> return s <EOL> hasnewline = ( s [ - <NUM_LIT:1> ] == '<STR_LIT:\n>' ) <EOL> value = base64 . encodestring ( s ) <EOL> if not hasnewline and value [ - <NUM_LIT:1> ] == '<STR_LIT:\n>' : <EOL> return value [ : - <NUM_LIT:1> ] <EOL> return value <EOL> def encode_base64 ( msg ) : <EOL> """<STR_LIT>""" <EOL> orig = msg . get_payload ( ) <EOL> encdata = _bencode ( orig ) <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> orig . encode ( '<STR_LIT:ascii>' ) <EOL> except UnicodeError : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> msg [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def encode_noop ( msg ) : <EOL> """<STR_LIT>""" </s>
