1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
Metadata-Version: 2.4
Name: sievelib
Version: 1.4.3
Summary: Client-side SIEVE library
Author-email: Antoine Nguyen <tonio@ngyn.org>
License: Copyright (c) 2011-2024 Antoine Nguyen <tonio@ngyn.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Project-URL: Repository, https://github.com/tonioo/sievelib
Project-URL: Issues, https://github.com/tonioo/sievelib/issues
Keywords: sieve,managesieve,parser,client
Classifier: Programming Language :: Python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Communications :: Email :: Filters
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: COPYING
Requires-Dist: typing-extensions
Provides-Extra: dev
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file
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/>`_)
* Notifications (`RFC 5435 <https://datatracker.ietf.org/doc/html/rfc5435>`_)
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``, ``OAUTHBEARER`` and ``XOAUTH2``.
Both explicit TLS via STARTTLS and implicit TLS are supported.
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:: https://codecov.io/github/tonioo/sievelib/graph/badge.svg?token=B1FWNSY60d
:target: https://codecov.io/github/tonioo/sievelib
|