PYTHON   33

text.py

Guest on 3rd June 2021 05:51:06 AM

  1. # Copyright (C)Python Software Foundation
  2. # Author: Barry Warsaw
  3.  
  4. """Class representing text/* type MIME documents."""
  5.  
  6. __all__ = ['MIMEText']
  7.  
  8. from email.encoders import encode_7or8bit
  9. from email.mime.nonmultipart import MIMENonMultipart
  10.  
  11.  
  12. class MIMEText(MIMENonMultipart):
  13.     """Class for generating text/* type MIME documents."""
  14.  
  15.     def __init__(self, _text, _subtype='plain', _charset='us-ascii'):
  16.         """Create a text/* type MIME document.
  17.  
  18.        _text is the string for this message object.
  19.  
  20.        _subtype is the MIME sub content type, defaulting to "plain".
  21.  
  22.        _charset is the character set parameter added to the Content-Type
  23.        header.  This defaults to "us-ascii".  Note that as a side-effect, the
  24.        Content-Transfer-Encoding header will also be set.
  25.        """
  26.         MIMENonMultipart.__init__(self, 'text', _subtype,
  27.                                   **{'charset': _charset})
  28.         self.set_payload(_text, _charset)

Raw Paste


Login or Register to edit or fork this paste. It's free.