parameters: (msg)
docstring: Set the Content-Transfer-Encoding header to 7bit or 8bit.
docstring_summary: Set the Content-Transfer-Encoding header to 7bit or 8bit.
docstring_tokens: Set the Content - Transfer - Encoding header to 7bit or 8bit .
function: def encode_7or8bit(msg):
      """Set the Content-Transfer-Encoding header to 7bit or 8bit."""
      orig = msg.get_payload()
      if orig is None:
          # There's no payload.  For backwards compatibility we use 7bit
          msg['Content-Transfer-Encoding'] = '7bit'
          return
      # We play a trick to make this go fast.  If encoding to ASCII succeeds, we
      # know the data must be 7bit, otherwise treat it as 8bit.
      try:
          orig.encode('ascii')
      except UnicodeError:
          msg['Content-Transfer-Encoding'] = '8bit'
      else:
          msg['Content-Transfer-Encoding'] = '7bit'
function_tokens: def encode_7or8bit ( msg ) : orig = msg . get_payload ( ) if orig is None : # There's no payload.  For backwards compatibility we use 7bit msg [ 'Content-Transfer-Encoding' ] = '7bit' return # We play a trick to make this go fast.  If encoding to ASCII succeeds, we # know the data must be 7bit, otherwise treat it as 8bit. try : orig . encode ( 'ascii' ) except UnicodeError : msg [ 'Content-Transfer-Encoding' ] = '8bit' else : msg [ 'Content-Transfer-Encoding' ] = '7bit'