seamustuohy / RTFDE

RTFDE: RTF De-Encapsulator - A python3 library for extracting encapsulated `HTML` & `plain text` content from the `RTF` bodies of .msg files.
GNU Lesser General Public License v3.0
7 stars 3 forks source link

RTFDE: RTF De-Encapsulator

A python3 library for extracting encapsulated HTML & plain text content from the RTF bodies of .msg files.

De-encapsulation enables previously encapsulated HTML and plain text content to be extracted and rendered as HTML and plain text instead of the encapsulating RTF content. After de-encapsulation, the HTML and plain text should differ only minimally from the original HTML or plain text content.

Features

Known Issues

Anti-Features (I don't intend to have this library do this.)

Installation

To install from the pip package.

pip3 install RTFDE

Usage

De-encapsulating HTML or TEXT

from RTFDE.deencapsulate import DeEncapsulator

with open('rtf_file', 'rb') as fp:
    raw_rtf  = fp.read()
    rtf_obj = DeEncapsulator(raw_rtf)
    rtf_obj.deencapsulate()
    if rtf_obj.content_type == 'html':
        print(rtf_obj.html)
    else:
        print(rtf_obj.text)

Enabling Logging

Any logging (including how verbose the logging is) can be handled by configuring logging. You can enable RTFDE's logging at the highest level by getting and setting the "RTFDE" logger.

log = logging.getLogger("RTFDE")
log.setLevel(logging.INFO)

To see how to enable more in-depth logging for debugging check out the CONTRIBUTING.md file.

# Now, get the log that you want
# The main logger is simply called RTFDE. That will get you all the *normal* logs.
requests_log = logging.getLogger("RTFDE")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

Contribute

Please check the contributing guidelines

License

Please see the license file for license information on RTFDE. If you have further questions related to licensing PLEASE create an issue about it on github.