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:
```python
import clingy
# List all attachments from an email file
clingy.find("email.txt")
# List all attachments from an email string
with open("email.txt") as file:
clingy.find(file.read())
# Save all attachments by filename
clingy.save("email.txt")
# Save all attachments by string
with open("email.txt") as file:
clingy.save(file.read())
# Save single attachment from email.message.Message object
attachments = clingy.find("email.txt")
clingy.save(attachments[0])
# Find all TXT files via glob pattern:
clingy.find("email.txt", glob="*.txt")
# Save all TXT files via regular expression:
clingy.save("email.txt", regex=r"^.+\.txt$")
```
The combo glob/regex matcher is also available for good measure:
```python
import clingy
clingy.match("foo.txt", glob="*.txt")
clingy.match("foo.txt", regex="\.txt$")
````
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:
```python
import clingy
# List all attachments from an email file
clingy.find("email.txt")
# List all attachments from an email string
with open("email.txt") as file:
clingy.find(file.read())
# Save all attachments by filename
clingy.save("email.txt")
# Save all attachments by string
with open("email.txt") as file:
clingy.save(file.read())
# Save single attachment from email.message.Message object
attachments = clingy.find("email.txt")
clingy.save(attachments[0])
# Find all TXT files via glob pattern:
clingy.find("email.txt", glob="*.txt")
# Save all TXT files via regular expression:
clingy.save("email.txt", regex=r"^.+\.txt$")
```
The combo glob/regex matcher is also available for good measure:
```python
import clingy
clingy.match("foo.txt", glob="*.txt")
clingy.match("foo.txt", regex="\.txt$")
````
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file clingy-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: clingy-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad8b60fb9ffe3b152075225da4723d882113894a17567b4816ab43659a4424a |
|
MD5 | 5276cca7387b9a438392b63ea846e1d1 |
|
BLAKE2b-256 | 36e96080e922f491c42213d0be6c337d165b9b87cc5d5e817588fd518490a1c5 |