Wrapper for SpamAssassin SPAMC deamon
Project description
SpamAssassin Client python module
This is a python wrapper for SpamAssissin's SPAMC deamon. It provides these methods:
- is_spam(level=5) -> bool
- SPAM status from SpamAssasin deamon
- get_score() -> float
- final score from SpamAssasin deamon
- get_fulltext() -> str
- full report from SpamAssasin deamon
- get_report_json() -> dict
- full report as JSON from SpamAssasin deamon
Installation
Install the SpamAssassin daemon and pytest:
sudo apt install spamassassin python-pytest
Use the PIP package manager to install this module:
python -m pip install spamassassin_client
Example
Module can be used in following way:
import os
from spamassassin_client import SpamAssassin
FILES = [dict(type='spam', name='sample-spam.txt'),
dict(type='ham', name='sample-nonspam.txt')]
def main():
path = os.path.dirname(__file__)
for test in FILES:
filename = os.path.join(path, test['name'])
with open(filename,"rb") as f:
print("\nProcessing file: {}".format(filename))
assassin = SpamAssassin(f.read())
print(assassin)
if assassin.is_spam():
print("The received message is considered spam with a score of {0}".format(assassin.get_score()))
print('\nreport_fulltext:', assassin.get_fulltext())
print('score:', assassin.get_score())
print('report_json:', assassin.get_report_json())
if __name__ == "__main__":
main()
Run tests
pytest -v
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spamassassin_client-0.0.4.tar.gz.
File metadata
- Download URL: spamassassin_client-0.0.4.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5309b5f8dc7b31a3a5ec81d868ab83420c0dce0f2ae44302cbb75846bee322bb
|
|
| MD5 |
72e868f58d68af23e559a80d67908b01
|
|
| BLAKE2b-256 |
24dcc1d7fd2792f3821680c714761d34ad02cb676f30c71babf3efe84ff5dad8
|
File details
Details for the file spamassassin_client-0.0.4-py3-none-any.whl.
File metadata
- Download URL: spamassassin_client-0.0.4-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc05377bbd4bdfcd7b98afd44b30cdee2ccaccda77e1d28e413396b52e2976ee
|
|
| MD5 |
76711590fd06a95dcff16130347e60dc
|
|
| BLAKE2b-256 |
c6b5cd74f5fbe7ed4672149f8c7d4f9c173512ee85e32ab09861ee776c0719b3
|