Skip to main content

claw

https://circleci.com/gh/tictail/claw.svg?style=svg

Claw, https://github.com/tictail/claw, is a library to extract message quotations and signatures. It is is a more light-weight version of the original https://github.com/mailgun/talon library.

Changelog

If you ever tried to parse message quotations or signatures you know that absence of any formatting standards in this area could make this task a nightmare. Hopefully this library will make your life much easier.

Installation

pip install claw

Usage

Here’s how you initialize the library and extract a reply from a text message:

import claw
from claw import quotations

claw.init()

text =  """Reply

-----Original Message-----

Quote"""

reply = quotations.extract_from(text, 'text/plain')
reply = quotations.extract_from_plain(text)
# reply == "Reply"

To extract a reply from html:

html = """Reply
<blockquote>

  <div>
    On 11-Apr-2011, at 6:54 PM, Bob &lt;bob@example.com&gt; wrote:
  </div>

  <div>
    Quote
  </div>

</blockquote>"""

reply = quotations.extract_from(html, 'text/html')
reply = quotations.extract_from_html(html)
# reply == "<html><body><p>Reply</p></body></html>"

Often the best way is the easiest one. Here’s how you can extract signature from email message without any machine learning fancy stuff:

from claw.signature import extract_signature


message = """Wow. Awesome!
--
Bob Smith"""

text, signature = extract_signature(message)
# text == "Wow. Awesome!"
# signature == "--\nBob Smith"

Quick and works like a charm 90% of the time. For other 10% you can use the power of machine learning algorithms. See the original talon implementation.

Development

virtualenv venv
source venv/bin/activate

make install

make test

Release new version:

Bump the version in setup.py and update CHANGELOG.md, and then:

make release

Metadata

Release files for claw 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claw 1.3.0
File Size Uploaded Provenance Actions
claw-1.3.0.tar.gz 24.9 kB Without provenance Details for claw-1.3.0.tar.gz

Release files / claw-1.3.0.tar.gz

Download URL claw-1.3.0.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f50322d5ce25e40374e84d3e694523dbc3241c47960da2159d2bde6aad3f699d
BLAKE2b-256 checksum
How to use checksums
c9c6e5c09ebd4ca2e8b410b54a2ce62099b7c6b898b16b54d26347d22020393a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for claw 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page