No project description provided
Project description
Emailed Before
A simple Python library for keeping track when emails about some topics were sent.
Installation
You can install the library from PyPI.
pip install emailed-before
Usage
First construct a SentEmails
instance:
from emailedbefore import SentEmails
sent_emails = SentEmails(sqlite_file)
sqlite_file
is the path to a Sqlite3 file. It will be created if it doesn't exist yet.
You can then register the fact that an email has been sent.
email = "someone@example.com"
topic = "Your library books are due"
sent_emails.register(email, topic)
To find out when emails about a topic were sent you can use the sent_at
method, which returns a list of datetimes. The list is ordered.
from datetime import datetime, timedelta
# Remind the user about those books again after a week.
datetimes = sent_emails.sent_at(email, topic)
if len(datetimes) and datetime.now() - datetimes[-1] > timedelta(days=7):
... # email the user
For convenience, there is also a method last_sent_at
which returns the datetime when the last email was sent (or None
if no email has been sent). So the previous code example can be rewritten as:
from datetime import datetime, timedelta
# Remind the user about those books again after a week.
last_sent = sent_emails.last_sent_at(email, topic)
if last_sent and datetime.now() - last_sent > timedelta(days=7):
... # email the user
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 Distribution
Built Distribution
File details
Details for the file emailed-before-0.2.0.tar.gz
.
File metadata
- Download URL: emailed-before-0.2.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fed752f9bc93d67774227eb1f778c16f14fca205bf14b5c034304262393e6dbe |
|
MD5 | 89ea771b40601b1e1477a53c1b8f52cd |
|
BLAKE2b-256 | c6779a302180f406821ecaced2e699ce01bf8c4149f832c42972139efe755e1f |
File details
Details for the file emailed_before-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: emailed_before-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4afde2810df1124fc6eec3c3b402f938e3202f946e36300a8729a90f58af49df |
|
MD5 | 0efe1005b3340eed8db8f71a2ac8e261 |
|
BLAKE2b-256 | 43da3d9929cf8cf7f889b6a6a8382eab40f366168f9c8b5775661bfcdbc3f60f |