jpayne@68: # Copyright (C) 2001-2006 Python Software Foundation jpayne@68: # Author: Keith Dart jpayne@68: # Contact: email-sig@python.org jpayne@68: jpayne@68: """Class representing application/* type MIME documents.""" jpayne@68: jpayne@68: __all__ = ["MIMEApplication"] jpayne@68: jpayne@68: from email import encoders jpayne@68: from email.mime.nonmultipart import MIMENonMultipart jpayne@68: jpayne@68: jpayne@68: class MIMEApplication(MIMENonMultipart): jpayne@68: """Class for generating application/* MIME documents.""" jpayne@68: jpayne@68: def __init__(self, _data, _subtype='octet-stream', jpayne@68: _encoder=encoders.encode_base64, *, policy=None, **_params): jpayne@68: """Create an application/* type MIME document. jpayne@68: jpayne@68: _data is a string containing the raw application data. jpayne@68: jpayne@68: _subtype is the MIME content type subtype, defaulting to jpayne@68: 'octet-stream'. jpayne@68: jpayne@68: _encoder is a function which will perform the actual encoding for jpayne@68: transport of the application data, defaulting to base64 encoding. jpayne@68: jpayne@68: Any additional keyword arguments are passed to the base class jpayne@68: constructor, which turns them into parameters on the Content-Type jpayne@68: header. jpayne@68: """ jpayne@68: if _subtype is None: jpayne@68: raise TypeError('Invalid application MIME subtype') jpayne@68: MIMENonMultipart.__init__(self, 'application', _subtype, policy=policy, jpayne@68: **_params) jpayne@68: self.set_payload(_data) jpayne@68: _encoder(self)