10a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Copyright (C) 2001-2006 Python Software Foundation 20a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Author: Barry Warsaw 30a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Contact: email-sig@python.org 40a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 50a8c90248264a8b26970b4473770bcc3df8515fJosh Gao"""Class representing text/* type MIME documents.""" 60a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 70a8c90248264a8b26970b4473770bcc3df8515fJosh Gao__all__ = ['MIMEText'] 80a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 90a8c90248264a8b26970b4473770bcc3df8515fJosh Gaofrom email.encoders import encode_7or8bit 100a8c90248264a8b26970b4473770bcc3df8515fJosh Gaofrom email.mime.nonmultipart import MIMENonMultipart 110a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 120a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 130a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 140a8c90248264a8b26970b4473770bcc3df8515fJosh Gaoclass MIMEText(MIMENonMultipart): 150a8c90248264a8b26970b4473770bcc3df8515fJosh Gao """Class for generating text/* type MIME documents.""" 160a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 170a8c90248264a8b26970b4473770bcc3df8515fJosh Gao def __init__(self, _text, _subtype='plain', _charset='us-ascii'): 180a8c90248264a8b26970b4473770bcc3df8515fJosh Gao """Create a text/* type MIME document. 190a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 200a8c90248264a8b26970b4473770bcc3df8515fJosh Gao _text is the string for this message object. 210a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 220a8c90248264a8b26970b4473770bcc3df8515fJosh Gao _subtype is the MIME sub content type, defaulting to "plain". 230a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 240a8c90248264a8b26970b4473770bcc3df8515fJosh Gao _charset is the character set parameter added to the Content-Type 250a8c90248264a8b26970b4473770bcc3df8515fJosh Gao header. This defaults to "us-ascii". Note that as a side-effect, the 260a8c90248264a8b26970b4473770bcc3df8515fJosh Gao Content-Transfer-Encoding header will also be set. 270a8c90248264a8b26970b4473770bcc3df8515fJosh Gao """ 280a8c90248264a8b26970b4473770bcc3df8515fJosh Gao MIMENonMultipart.__init__(self, 'text', _subtype, 290a8c90248264a8b26970b4473770bcc3df8515fJosh Gao **{'charset': _charset}) 300a8c90248264a8b26970b4473770bcc3df8515fJosh Gao self.set_payload(_text, _charset) 31