sievelib


Namesievelib JSON
Version 1.4.0 PyPI version JSON
download
home_pagehttps://github.com/tonioo/sievelib
SummaryClient-side SIEVE library
upload_time2024-04-11 08:02:09
maintainerNone
docs_urlNone
authorAntoine Nguyen
requires_python>=3.7
licenseMIT
keywords sieve managesieve parser client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            sievelib
========

|workflow| |codecov| |latest-version|

Client-side Sieve and Managesieve library written in Python.

* Sieve : An Email Filtering Language
  (`RFC 5228 <http://tools.ietf.org/html/rfc5228>`_)
* ManageSieve : A Protocol for Remotely Managing Sieve Scripts
  (`RFC 5804 <http://tools.ietf.org/html/rfc5804>`_)

Installation
------------

To install ``sievelib`` from PyPI::

  pip install sievelib

To install sievelib from git::

  git clone git@github.com:tonioo/sievelib.git
  cd sievelib
  python ./setup.py install

Sieve tools
-----------

What is supported
^^^^^^^^^^^^^^^^^

Currently, the provided parser supports most of the functionalities
described in the RFC. The only exception concerns section
*2.4.2.4. Encoding Characters Using "encoded-character"* which is not
supported.

The following extensions are also supported:

* Copying Without Side Effects (`RFC 3894 <https://tools.ietf.org/html/rfc3894>`_)
* Body (`RFC 5173 <https://tools.ietf.org/html/rfc5173>`_)
* Vacation (`RFC 5230 <http://tools.ietf.org/html/rfc5230>`_)
* Seconds parameter for Vacation (`RFC 6131 <https://datatracker.ietf.org/doc/html/rfc6131>`_)
* Relational (`RFC 5231 <https://tools.ietf.org/html/rfc5231>`_)
* Imap4flags (`RFC 5232 <https://tools.ietf.org/html/rfc5232>`_)
* Regular expression (`Draft <https://datatracker.ietf.org/doc/html/draft-murchison-sieve-regex-08/>`_)

The following extensions are partially supported:

* Date and Index (`RFC 5260 <https://tools.ietf.org/html/rfc5260>`_)
* Checking Mailbox Status and Accessing Mailbox Metadata (`RFC 5490 <https://tools.ietf.org/html/rfc5490>`_)

Extending the parser
^^^^^^^^^^^^^^^^^^^^

It is possible to extend the parser by adding new supported
commands. For example::

  import sievelib

  class MyCommand(sievelib.commands.ActionCommand):
      args_definition = [
          {"name": "testtag",
              "type": ["tag"],
              "write_tag": True,
              "values": [":testtag"],
              "extra_arg": {"type": "number",
                            "required": False},
              "required": False},
          {"name": "recipients",
              "type": ["string", "stringlist"],
              "required": True}
      ]

  sievelib.commands.add_commands(MyCommand)

Basic usage
^^^^^^^^^^^

The parser can either be used from the command-line::

  $ cd sievelib
  $ python parser.py test.sieve
  Syntax OK
  $

Or can be used from a python environment (or script/module)::

  >>> from sievelib.parser import Parser
  >>> p = Parser()
  >>> p.parse('require ["fileinto"];')
  True
  >>> p.dump()
  require (type: control)
      ["fileinto"]
  >>> 
  >>> p.parse('require ["fileinto"]')
  False
  >>> p.error
  'line 1: parsing error: end of script reached while semicolon expected'
  >>>

Simple filters creation
^^^^^^^^^^^^^^^^^^^^^^^

Some high-level classes are provided with the ``factory`` module, they
make the generation of Sieve rules easier::

  >>> from sievelib.factory import FiltersSet
  >>> fs = FiltersSet("test")
  >>> fs.addfilter("rule1",
  ...              [("Sender", ":is", "toto@toto.com"),],
  ...              [("fileinto", "Toto"),])
  >>> fs.tosieve()
  require ["fileinto"];
  
  # Filter: rule1
  if anyof (header :is "Sender" "toto@toto.com") {
      fileinto "Toto";
  }
  >>> 

Additional documentation is available within source code.

ManageSieve tools
-----------------

What is supported
^^^^^^^^^^^^^^^^^

All mandatory commands are supported. The ``RENAME`` extension is
supported, with a simulated behaviour for server that do not support
it.

For the ``AUTHENTICATE`` command, supported mechanisms are ``DIGEST-MD5``,
``PLAIN``, ``LOGIN`` and ``OAUTHBEARER``.
    
Basic usage
^^^^^^^^^^^

The ManageSieve client is intended to be used from another python
application (there isn't any shell provided)::

  >>> from sievelib.managesieve import Client
  >>> c = Client("server.example.com")
  >>> c.connect("user", "password", starttls=False, authmech="DIGEST-MD5")
  True
  >>> c.listscripts()
  ("active_script", ["script1", "script2"])
  >>> c.setactive("script1")
  True
  >>> c.havespace("script3", 45)
  True
  >>>

Additional documentation is available with source code.

.. |latest-version| image:: https://badge.fury.io/py/sievelib.svg
   :target: https://badge.fury.io/py/sievelib
.. |workflow| image:: https://github.com/tonioo/sievelib/workflows/Sievelib/badge.svg
.. |codecov| image:: http://codecov.io/github/tonioo/sievelib/coverage.svg?branch=master
   :target: http://codecov.io/github/tonioo/sievelib?branch=master

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tonioo/sievelib",
    "name": "sievelib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "sieve, managesieve, parser, client",
    "author": "Antoine Nguyen",
    "author_email": "tonio@ngyn.org",
    "download_url": "https://files.pythonhosted.org/packages/65/96/b7815e06681c2d519c7202a329c91fe5d2097f4fe33cd047fc5de816196d/sievelib-1.4.0.tar.gz",
    "platform": null,
    "description": "sievelib\n========\n\n|workflow| |codecov| |latest-version|\n\nClient-side Sieve and Managesieve library written in Python.\n\n* Sieve : An Email Filtering Language\n  (`RFC 5228 <http://tools.ietf.org/html/rfc5228>`_)\n* ManageSieve : A Protocol for Remotely Managing Sieve Scripts\n  (`RFC 5804 <http://tools.ietf.org/html/rfc5804>`_)\n\nInstallation\n------------\n\nTo install ``sievelib`` from PyPI::\n\n  pip install sievelib\n\nTo install sievelib from git::\n\n  git clone git@github.com:tonioo/sievelib.git\n  cd sievelib\n  python ./setup.py install\n\nSieve tools\n-----------\n\nWhat is supported\n^^^^^^^^^^^^^^^^^\n\nCurrently, the provided parser supports most of the functionalities\ndescribed in the RFC. The only exception concerns section\n*2.4.2.4. Encoding Characters Using \"encoded-character\"* which is not\nsupported.\n\nThe following extensions are also supported:\n\n* Copying Without Side Effects (`RFC 3894 <https://tools.ietf.org/html/rfc3894>`_)\n* Body (`RFC 5173 <https://tools.ietf.org/html/rfc5173>`_)\n* Vacation (`RFC 5230 <http://tools.ietf.org/html/rfc5230>`_)\n* Seconds parameter for Vacation (`RFC 6131 <https://datatracker.ietf.org/doc/html/rfc6131>`_)\n* Relational (`RFC 5231 <https://tools.ietf.org/html/rfc5231>`_)\n* Imap4flags (`RFC 5232 <https://tools.ietf.org/html/rfc5232>`_)\n* Regular expression (`Draft <https://datatracker.ietf.org/doc/html/draft-murchison-sieve-regex-08/>`_)\n\nThe following extensions are partially supported:\n\n* Date and Index (`RFC 5260 <https://tools.ietf.org/html/rfc5260>`_)\n* Checking Mailbox Status and Accessing Mailbox Metadata (`RFC 5490 <https://tools.ietf.org/html/rfc5490>`_)\n\nExtending the parser\n^^^^^^^^^^^^^^^^^^^^\n\nIt is possible to extend the parser by adding new supported\ncommands. For example::\n\n  import sievelib\n\n  class MyCommand(sievelib.commands.ActionCommand):\n      args_definition = [\n          {\"name\": \"testtag\",\n              \"type\": [\"tag\"],\n              \"write_tag\": True,\n              \"values\": [\":testtag\"],\n              \"extra_arg\": {\"type\": \"number\",\n                            \"required\": False},\n              \"required\": False},\n          {\"name\": \"recipients\",\n              \"type\": [\"string\", \"stringlist\"],\n              \"required\": True}\n      ]\n\n  sievelib.commands.add_commands(MyCommand)\n\nBasic usage\n^^^^^^^^^^^\n\nThe parser can either be used from the command-line::\n\n  $ cd sievelib\n  $ python parser.py test.sieve\n  Syntax OK\n  $\n\nOr can be used from a python environment (or script/module)::\n\n  >>> from sievelib.parser import Parser\n  >>> p = Parser()\n  >>> p.parse('require [\"fileinto\"];')\n  True\n  >>> p.dump()\n  require (type: control)\n      [\"fileinto\"]\n  >>> \n  >>> p.parse('require [\"fileinto\"]')\n  False\n  >>> p.error\n  'line 1: parsing error: end of script reached while semicolon expected'\n  >>>\n\nSimple filters creation\n^^^^^^^^^^^^^^^^^^^^^^^\n\nSome high-level classes are provided with the ``factory`` module, they\nmake the generation of Sieve rules easier::\n\n  >>> from sievelib.factory import FiltersSet\n  >>> fs = FiltersSet(\"test\")\n  >>> fs.addfilter(\"rule1\",\n  ...              [(\"Sender\", \":is\", \"toto@toto.com\"),],\n  ...              [(\"fileinto\", \"Toto\"),])\n  >>> fs.tosieve()\n  require [\"fileinto\"];\n  \n  # Filter: rule1\n  if anyof (header :is \"Sender\" \"toto@toto.com\") {\n      fileinto \"Toto\";\n  }\n  >>> \n\nAdditional documentation is available within source code.\n\nManageSieve tools\n-----------------\n\nWhat is supported\n^^^^^^^^^^^^^^^^^\n\nAll mandatory commands are supported. The ``RENAME`` extension is\nsupported, with a simulated behaviour for server that do not support\nit.\n\nFor the ``AUTHENTICATE`` command, supported mechanisms are ``DIGEST-MD5``,\n``PLAIN``, ``LOGIN`` and ``OAUTHBEARER``.\n    \nBasic usage\n^^^^^^^^^^^\n\nThe ManageSieve client is intended to be used from another python\napplication (there isn't any shell provided)::\n\n  >>> from sievelib.managesieve import Client\n  >>> c = Client(\"server.example.com\")\n  >>> c.connect(\"user\", \"password\", starttls=False, authmech=\"DIGEST-MD5\")\n  True\n  >>> c.listscripts()\n  (\"active_script\", [\"script1\", \"script2\"])\n  >>> c.setactive(\"script1\")\n  True\n  >>> c.havespace(\"script3\", 45)\n  True\n  >>>\n\nAdditional documentation is available with source code.\n\n.. |latest-version| image:: https://badge.fury.io/py/sievelib.svg\n   :target: https://badge.fury.io/py/sievelib\n.. |workflow| image:: https://github.com/tonioo/sievelib/workflows/Sievelib/badge.svg\n.. |codecov| image:: http://codecov.io/github/tonioo/sievelib/coverage.svg?branch=master\n   :target: http://codecov.io/github/tonioo/sievelib?branch=master\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Client-side SIEVE library",
    "version": "1.4.0",
    "project_urls": {
        "Homepage": "https://github.com/tonioo/sievelib"
    },
    "split_keywords": [
        "sieve",
        " managesieve",
        " parser",
        " client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6596b7815e06681c2d519c7202a329c91fe5d2097f4fe33cd047fc5de816196d",
                "md5": "013a2626d179fa9830b11acd0024231b",
                "sha256": "78cf1eb3f59910d1410128ce9352956dbc249b3c53afb362ace8922edec5dcdf"
            },
            "downloads": -1,
            "filename": "sievelib-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "013a2626d179fa9830b11acd0024231b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 37563,
            "upload_time": "2024-04-11T08:02:09",
            "upload_time_iso_8601": "2024-04-11T08:02:09.163305Z",
            "url": "https://files.pythonhosted.org/packages/65/96/b7815e06681c2d519c7202a329c91fe5d2097f4fe33cd047fc5de816196d/sievelib-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-11 08:02:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tonioo",
    "github_project": "sievelib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "sievelib"
}
        
Elapsed time: 0.21345s