aiospamc


Nameaiospamc JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/mjcaley/aiospamc
SummaryAn asyncio-based library to communicate with SpamAssassin's SPAMD service.
upload_time2023-10-11 13:36:29
maintainer
docs_urlNone
authorMichael Caley
requires_python>=3.8,<4.0
licenseMIT
keywords spam spamc spamassassin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ########
aiospamc
########

|pypi| |docs| |license| |unit| |integration| |python|

.. |pypi| image:: https://img.shields.io/pypi/v/aiospamc
    :target: https://pypi.org/project/aiospamc/

.. |unit| image:: https://github.com/mjcaley/aiospamc/actions/workflows/unit-tests.yml/badge.svg
    :target: https://github.com/mjcaley/aiospamc/actions/workflows/unit-tests.yml

.. |integration| image:: https://github.com/mjcaley/aiospamc/actions/workflows/integration-tests.yml/badge.svg
    :target: https://github.com/mjcaley/aiospamc/actions/workflows/integration-tests.yml

.. |docs| image:: https://readthedocs.org/projects/aiospamc/badge/?version=latest
    :target: https://aiospamc.readthedocs.io/en/latest/

.. |license| image:: https://img.shields.io/github/license/mjcaley/aiospamc
    :target: ./LICENSE

.. |python| image:: https://img.shields.io/pypi/pyversions/aiospamc
    :target: https://python.org

**aiospamc** is a client for SpamAssassin that you can use as a library or command line tool.

The implementation is based on asyncio; so you can use it in your applications for asynchronous calls.

The command line interface provides user-friendly access to SpamAssassin server commands and provides both JSON
and user-consumable outputs.

*************
Documentation
*************

Detailed documentation can be found at: https://aiospamc.readthedocs.io/

************
Requirements
************

* Python 3.8 or higher
* `certifi` for updated certificate authorities
* `loguru` for structured logging
* `typer` for the command line interface

********
Examples
********

Command-Line Tool
=================

`aiospamc` is your interface to SpamAssassin through CLI. To submit a message
for a score, use:

.. code-block:: console

    # Take the output of gtube.msg and have SpamAssasin return a score
    $ cat ./gtube.msg | aiospamc check
    1000.0/5.0

    # Ping the server
    $ aiospamc ping
    PONG

Library
=======

.. code-block:: python

    import asyncio
    import aiospamc


    GTUBE = """Subject: Test spam mail (GTUBE)
    Message-ID: <GTUBE1.1010101@example.net>
    Date: Wed, 23 Jul 2003 23:30:00 +0200
    From: Sender <sender@example.net>
    To: Recipient <recipient@example.net>
    Precedence: junk
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit

    This is the GTUBE, the
        Generic
        Test for
        Unsolicited
        Bulk
        Email

    If your spam filter supports it, the GTUBE provides a test by which you
    can verify that the filter is installed correctly and is detecting incoming
    spam. You can send yourself a test mail containing the following string of
    characters (in upper case and with no white spaces and line breaks):

    XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

    You should send this test mail from an account outside of your network.
    """.encode("ascii")


    # Ping the SpamAssassin server
    async def is_alive():
        pong = await aiospamc.ping()
        return True if pong.status_code == 0 else False

    asyncio.run(is_alive())
    # True


    # Get the spam score of a message
    async def get_score(message):
        response = await aiospamc.check(message)
        return response.headers.spam.score, response.headers.spam.threshold

    asyncio.run(get_score(GTUBE))
    # (1000.0, 5.0)


    # List the modified headers
    async def list_headers(message):
        response = await aiospamc.headers(message)
        for line in response.body.splitlines():
            print(line.decode())

    asyncio.run(list_headers(GTUBE))
    # Received: from localhost by DESKTOP.
    #         with SpamAssassin (version 4.0.0);
    #         Wed, 30 Aug 2023 20:11:34 -0400
    # From: Sender <sender@example.net>
    # To: Recipient <recipient@example.net>
    # Subject: Test spam mail (GTUBE)
    # Date: Wed, 23 Jul 2003 23:30:00 +0200
    # Message-Id: <GTUBE1.1010101@example.net>
    # X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on DESKTOP.
    # X-Spam-Flag: YES
    # X-Spam-Level: **************************************************
    # X-Spam-Status: Yes, score=1000.0 required=5.0 tests=GTUBE,NO_RECEIVED,
    #         NO_RELAYS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no
    #         version=4.0.0
    # MIME-Version: 1.0
    # Content-Type: multipart/mixed; boundary="----------=_64EFDAB6.3640FAEF"


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mjcaley/aiospamc",
    "name": "aiospamc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "spam,spamc,spamassassin",
    "author": "Michael Caley",
    "author_email": "mjcaley@darkarctic.com",
    "download_url": "https://files.pythonhosted.org/packages/ac/7f/dce3c6a3c0a37b089f4974c2d4fa1e403496c38d838705c4e79bf30dd618/aiospamc-1.0.0.tar.gz",
    "platform": null,
    "description": "########\naiospamc\n########\n\n|pypi| |docs| |license| |unit| |integration| |python|\n\n.. |pypi| image:: https://img.shields.io/pypi/v/aiospamc\n    :target: https://pypi.org/project/aiospamc/\n\n.. |unit| image:: https://github.com/mjcaley/aiospamc/actions/workflows/unit-tests.yml/badge.svg\n    :target: https://github.com/mjcaley/aiospamc/actions/workflows/unit-tests.yml\n\n.. |integration| image:: https://github.com/mjcaley/aiospamc/actions/workflows/integration-tests.yml/badge.svg\n    :target: https://github.com/mjcaley/aiospamc/actions/workflows/integration-tests.yml\n\n.. |docs| image:: https://readthedocs.org/projects/aiospamc/badge/?version=latest\n    :target: https://aiospamc.readthedocs.io/en/latest/\n\n.. |license| image:: https://img.shields.io/github/license/mjcaley/aiospamc\n    :target: ./LICENSE\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/aiospamc\n    :target: https://python.org\n\n**aiospamc** is a client for SpamAssassin that you can use as a library or command line tool.\n\nThe implementation is based on asyncio; so you can use it in your applications for asynchronous calls.\n\nThe command line interface provides user-friendly access to SpamAssassin server commands and provides both JSON\nand user-consumable outputs.\n\n*************\nDocumentation\n*************\n\nDetailed documentation can be found at: https://aiospamc.readthedocs.io/\n\n************\nRequirements\n************\n\n* Python 3.8 or higher\n* `certifi` for updated certificate authorities\n* `loguru` for structured logging\n* `typer` for the command line interface\n\n********\nExamples\n********\n\nCommand-Line Tool\n=================\n\n`aiospamc` is your interface to SpamAssassin through CLI. To submit a message\nfor a score, use:\n\n.. code-block:: console\n\n    # Take the output of gtube.msg and have SpamAssasin return a score\n    $ cat ./gtube.msg | aiospamc check\n    1000.0/5.0\n\n    # Ping the server\n    $ aiospamc ping\n    PONG\n\nLibrary\n=======\n\n.. code-block:: python\n\n    import asyncio\n    import aiospamc\n\n\n    GTUBE = \"\"\"Subject: Test spam mail (GTUBE)\n    Message-ID: <GTUBE1.1010101@example.net>\n    Date: Wed, 23 Jul 2003 23:30:00 +0200\n    From: Sender <sender@example.net>\n    To: Recipient <recipient@example.net>\n    Precedence: junk\n    MIME-Version: 1.0\n    Content-Type: text/plain; charset=us-ascii\n    Content-Transfer-Encoding: 7bit\n\n    This is the GTUBE, the\n        Generic\n        Test for\n        Unsolicited\n        Bulk\n        Email\n\n    If your spam filter supports it, the GTUBE provides a test by which you\n    can verify that the filter is installed correctly and is detecting incoming\n    spam. You can send yourself a test mail containing the following string of\n    characters (in upper case and with no white spaces and line breaks):\n\n    XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X\n\n    You should send this test mail from an account outside of your network.\n    \"\"\".encode(\"ascii\")\n\n\n    # Ping the SpamAssassin server\n    async def is_alive():\n        pong = await aiospamc.ping()\n        return True if pong.status_code == 0 else False\n\n    asyncio.run(is_alive())\n    # True\n\n\n    # Get the spam score of a message\n    async def get_score(message):\n        response = await aiospamc.check(message)\n        return response.headers.spam.score, response.headers.spam.threshold\n\n    asyncio.run(get_score(GTUBE))\n    # (1000.0, 5.0)\n\n\n    # List the modified headers\n    async def list_headers(message):\n        response = await aiospamc.headers(message)\n        for line in response.body.splitlines():\n            print(line.decode())\n\n    asyncio.run(list_headers(GTUBE))\n    # Received: from localhost by DESKTOP.\n    #         with SpamAssassin (version 4.0.0);\n    #         Wed, 30 Aug 2023 20:11:34 -0400\n    # From: Sender <sender@example.net>\n    # To: Recipient <recipient@example.net>\n    # Subject: Test spam mail (GTUBE)\n    # Date: Wed, 23 Jul 2003 23:30:00 +0200\n    # Message-Id: <GTUBE1.1010101@example.net>\n    # X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on DESKTOP.\n    # X-Spam-Flag: YES\n    # X-Spam-Level: **************************************************\n    # X-Spam-Status: Yes, score=1000.0 required=5.0 tests=GTUBE,NO_RECEIVED,\n    #         NO_RELAYS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no\n    #         version=4.0.0\n    # MIME-Version: 1.0\n    # Content-Type: multipart/mixed; boundary=\"----------=_64EFDAB6.3640FAEF\"\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An asyncio-based library to communicate with SpamAssassin's SPAMD service.",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://aiospamc.readthedocs.io",
        "Homepage": "https://github.com/mjcaley/aiospamc",
        "Repository": "https://github.com/mjcaley/aiospamc"
    },
    "split_keywords": [
        "spam",
        "spamc",
        "spamassassin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b21342cf746579b756d2cb73325afb09e615aabc362039232ce0777d779e7608",
                "md5": "5f920002d74a8a26cfcbdd8a877d869e",
                "sha256": "7f5204fd02a0434e94b23a34cecf74c66435dacbfeabb84e753c8e4c16fb36c0"
            },
            "downloads": -1,
            "filename": "aiospamc-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f920002d74a8a26cfcbdd8a877d869e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 27779,
            "upload_time": "2023-10-11T13:36:27",
            "upload_time_iso_8601": "2023-10-11T13:36:27.614310Z",
            "url": "https://files.pythonhosted.org/packages/b2/13/42cf746579b756d2cb73325afb09e615aabc362039232ce0777d779e7608/aiospamc-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac7fdce3c6a3c0a37b089f4974c2d4fa1e403496c38d838705c4e79bf30dd618",
                "md5": "aa06a49619e04fcf8c0805a82cbbe32a",
                "sha256": "e03d214a6e530d083dbabac9dc4982f6cb5cefd6df8554480c2deda4ed9ac72e"
            },
            "downloads": -1,
            "filename": "aiospamc-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "aa06a49619e04fcf8c0805a82cbbe32a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 24748,
            "upload_time": "2023-10-11T13:36:29",
            "upload_time_iso_8601": "2023-10-11T13:36:29.231449Z",
            "url": "https://files.pythonhosted.org/packages/ac/7f/dce3c6a3c0a37b089f4974c2d4fa1e403496c38d838705c4e79bf30dd618/aiospamc-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-11 13:36:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mjcaley",
    "github_project": "aiospamc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiospamc"
}
        
Elapsed time: 0.12950s