Skip to main content

A library that identifies quoted text in plain text and HTML email messages.

Project description

A library that identifies quoted text in plain text and HTML email messages. quotequail has no mandatory dependencies, however using HTML methods require libxml.

(Interested in working on projects like this? Close.io is looking for great engineers to join our team)

Introduction

quotequail comes with the functions listed below which are documented in detail in quotequail’s __init__.py.

  • quote(text): Takes a plain text message as an argument, returns a list of tuples. The first argument of the tuple denotes whether the text should be expanded by default. The second argument is the unmodified corresponding text.

  • quote_html(html): Like quote(), but takes an HTML message as an argument.

  • unwrap(text): If the passed text is the text body of a forwarded message, a reply, or contains quoted text, a dictionary is returned, containing the type (reply/forward/quote), the text at the top/bottom of the wrapped message, any parsed headers, and the text of the wrapped message.

  • unwrap_html(text): Like unwrap(), but takes an HTML message as an argument.

Examples

In [1]: import quotequail

In [2]: quotequail.quote("""Hello world.

On 2012-10-16 at 17:02 , Someone <someone@example.com> wrote:

> Some quoted text
""")
Out[2]:
[(True, 'Hello world.\n\nOn 2012-10-16 at 17:02 , Someone <someone@example.com> wrote:'),
 (False, '\n> Some quoted text\n')]

In [3]: quotequail.unwrap("""Hello

Begin forwarded message:

> From: "Some One" <some.one@example.com>
> Date: 1. August 2011 23:28:15 GMT-07:00
> To: "Other Person" <other@example.com>
> Subject: AW: AW: Some subject
>
> Original text

Text bottom
"""))
Out[3]:
{'date': '1. August 2011 23:28:15 GMT-07:00',
 'from': '"Some One" <some.one@example.com>',
 'subject': 'AW: AW: Some subject',
 'text': 'Original text',
 'text_bottom': 'Text bottom',
 'text_top': 'Hello',
 'to': '"Other Person" <other@example.com>',
 'type': 'forward'}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quotequail-0.4.0.tar.gz (15.1 kB view details)

Uploaded Source

File details

Details for the file quotequail-0.4.0.tar.gz.

File metadata

  • Download URL: quotequail-0.4.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for quotequail-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7db731bde681be769116438404932b8041c1f0f58b14eaec4bc8d56543e8c633
MD5 ec88486c43f9d836a127b414bc60deff
BLAKE2b-256 604916ed6282db0813fb97182a3a47ef7274e8b7e666d17f6bba46d4366cc023

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page