Skip to main content

A tool to save attachments from plain text emails

Project description

Clingy lets you save attachments from plain text emails.

From the command line, you can use it like this:

clingy email1.txt email2.txt email3.txt

By default, the attachments will be saved into the current directory.
You can specify a different directory using `-d` or `--directory` like so,
and the directory will be created if it does not exist:

clingy email.txt -d out

You can save specific attachments using glob patterns (`-g` or `--glob`)
and regular expressions (`-r` or `--regex`):

clingy email.txt -g "*.txt"
clingy email.txt -r "^.+\.txt$"

When you `pip install clingy`, Python will create a platform-appropriate
executable in the Python Scripts directory. Assuming you have that directory
in your path, you can just run `clingy` from the console.

You can also use it as a library:

import clingy

# List all attachments from an email file

# List all attachments from an email string
with open("email.txt") as file:

# Save all attachments by filename"email.txt")

# Save all attachments by string
with open("email.txt") as file:

# Save single attachment from email.message.Message object
attachments = clingy.find("email.txt")[0])

# Find all TXT files via glob pattern:
clingy.find("email.txt", glob="*.txt")

# Save all TXT files via regular expression:"email.txt", regex=r"^.+\.txt$")

The combo glob/regex matcher is also available for good measure:

import clingy

clingy.match("foo.txt", glob="*.txt")
clingy.match("foo.txt", regex="\.txt$")

Project details

Download files

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

Files for clingy, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size clingy-1.0.0-py2.py3-none-any.whl (5.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page