Wrapper for SpamAssassin SPAMC deamon
Project description
# SpamAssassin Client python module
This is a python wrapper for SpamAssissin's SPAMC deamon. It provides these funtions:
* get_score(float) - final score from spamassasin
* get_fulltext(string) - full report as string from SpamAssasin deamon
* get_report_json(json) - full report as JSON from SpamAssasin deamon
# Instalation
Install SpamAssassin
sudo apt get spamassassin
Pytest needs to be installed to run tests
sudo apt install python-pytest
Use PIP package manager to install this module
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
This is a python wrapper for SpamAssissin's SPAMC deamon. It provides these funtions:
* get_score(float) - final score from spamassasin
* get_fulltext(string) - full report as string from SpamAssasin deamon
* get_report_json(json) - full report as JSON from SpamAssasin deamon
# Instalation
Install SpamAssassin
sudo apt get spamassassin
Pytest needs to be installed to run tests
sudo apt install python-pytest
Use PIP package manager to install this module
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.1.tar.gz.
File metadata
- Download URL: spamassassin_client-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4219d7f52656f7dbae2dab81a32b624aba8f4a4c677668e34e67c66d632f71e
|
|
| MD5 |
5bfaa66ce82b21d29f73dc15966f707a
|
|
| BLAKE2b-256 |
4c106c8b571f44f5f68d4b63c787e82fe8e366ea957adbba016cce54c2adaf14
|
File details
Details for the file spamassassin_client-0.0.1-py3-none-any.whl.
File metadata
- Download URL: spamassassin_client-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7be645a2f54f114b1589bdfc64629314dcb208120b937784e9be4b5eee17a31f
|
|
| MD5 |
5798fa3a95dd9778be7436015951a6d3
|
|
| BLAKE2b-256 |
8f4a07eca6e1c453392602027d65a17dc77f71c4ac0678bb596ead307695a3ee
|