IPWorks OpenPGP 2020 Python Edition

Questions / Feedback?

MIME Class

Properties   Methods   Events   Configuration Settings   Errors  

The MIME class allows for the simple encoding and decoding of MIME structures such as message attachments, file uploads, etc.

Syntax

class ipworksopenpgp.MIME

Remarks

The class may be used for decoding or encoding of messages. message holds the content of the encoded message or the filename which holds the encoded data. The decoded data is provided in parts properties.

To decode a MIME message you should first assign either the whole message (headers and body) to message or put the message headers into the message_headers property and the message body or the filename holding it into the message property. Calling decode_from_file or decode_from_string directs the class to start parsing the message: it will fill out the content_type, content_type_attr properties with message content type information, and enter information about message parts into the parts properties, which includes: part sizes, part content types, part content type attributes, part content disposition, part content disposition attributes, part encoding, part name, part filename, part headers, or part content (part decoded string or part decoded file) for each decoded part.

Calling the decode_from_string or decode_from_file to decode doesn't actually decode the message but only parses it. The real decoding is done when the part content in the parts properties is first accessed.

To encode data into a MIME message you should first assign values for each part to either part decoded string or part decoded file in the parts properties property, and optionally assign values to the other part attributes in the parts properties. Assigning a value to the part decoded string or part decoded file through the parts properties, fills out automatically the part headers into the parts properties for the respective part. Calling encode_to_file or encode_to_string directs the class to fill out the message with the message body and the message_headers with the headers.

The on_progress event is fired as the message is parsed and the data is decoded/encoded.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

boundaryThe boundary separating the MIME parts. Maximum length of 80 bytes.
content_typeThe value of the content-type header of the message which was encoded/decoded.
content_type_attrThe attributes for content-type header of the message which was encoded/decoded.
messageContains the encoded message text or a path to a file which contains the encoded message text.
message_header_countThe number of records in the MessageHeader arrays.
message_header_fieldThis property contains the name of the HTTP header (same case as it is delivered).
message_header_valueThis property contains the header contents.
message_headers_stringString version of the MIME message headers.
part_countThe number of records in the Part arrays.
part_content_dispositionContent disposition for each part.
part_content_disposition_attrThe content disposition's attribute (if any) for each part.
part_content_idContent identifier for each part.
part_content_typeContent type for each part.
part_content_type_attrThe content type attribute, if any, for each part.
part_decoded_fileThe filename with the decoded data.
part_decoded_stringThis property holds the actual content of each part.
part_encodingThis property contains the actual content encoding type for each part.
part_filenameThis property contains the filename attribute specified in the headers of the part.
part_headersThis property contains the headers for each MIME part.
part_nameThis property contains the name given to a part, such as the filename.
part_sizeThis property contains the size of the DecodedFile or DecodedString .

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

configSets or retrieves a configuration setting.
decode_from_fileDecodes from file.
decode_from_stringDecodes from string.
encode_to_fileEncodes to file.
encode_to_stringEncodes to string.
resetReset the class.
reset_dataResets the values of all headers and Part- properties.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_errorInformation about errors during data delivery.
on_headerFired every time a header is parsed.
on_progressShows the progress of decoding/encoding the input data.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

DecodeMessageHeadersInstructs the class to automatically decode message headers.
IncludeHeadersTells the class whether to include the headers when encoding the message.
RequireVersionHeaderSpecifies whether or not the class should require the version header.
SanitizeFilenameWhether invalid characters are replaced in MIME part filenames.
TempFilePathIf set, the temporary files created during MIME decoding and encoding will be put in the path specified.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks OpenPGP 2020 Python Edition - Version 20.0 [Build 8249]