Client-side SIEVE library
Project description
Client-side Sieve and Managesieve library written in Python.
Sieve : An Email Filtering Language (RFC 5228)
ManageSieve : A Protocol for Remotely Managing Sieve Scripts (RFC 5804)
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)
Body (RFC 5173)
Vacation (RFC 5230)
Seconds parameter for Vacation (RFC 6131)
Relational (RFC 5231)
Imap4flags (RFC 5232)
Regular expression (Draft)
Notifications (RFC 5435)
The following extensions are partially supported:
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.
Project details
Release history Release notifications | RSS feed
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 sievelib-1.4.3.tar.gz.
File metadata
- Download URL: sievelib-1.4.3.tar.gz
- Upload date:
- Size: 39.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c57a65af01ce966c90b13e52f14fbf9a7037767a071b8381474cc5ab23104f4
|
|
| MD5 |
1151e16b652aef9b950eb81cc54b7b3f
|
|
| BLAKE2b-256 |
09e3a5e81d9dde5bc0e455717e44dc706ab812bff69e8b1fac27e5a814e20af3
|
Provenance
The following attestation bundles were made for sievelib-1.4.3.tar.gz:
Publisher:
sievelib.yml on tonioo/sievelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sievelib-1.4.3.tar.gz -
Subject digest:
6c57a65af01ce966c90b13e52f14fbf9a7037767a071b8381474cc5ab23104f4 - Sigstore transparency entry: 724638769
- Sigstore integration time:
-
Permalink:
tonioo/sievelib@69f644c9dcc4ce1cb6b0c19d3680491979d3608e -
Branch / Tag:
refs/tags/1.4.3 - Owner: https://github.com/tonioo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sievelib.yml@69f644c9dcc4ce1cb6b0c19d3680491979d3608e -
Trigger Event:
release
-
Statement type:
File details
Details for the file sievelib-1.4.3-py3-none-any.whl.
File metadata
- Download URL: sievelib-1.4.3-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58e6fb446c47166957816b34fc8a8acc912a0bb3f6aa6cc8fd65fc8f16013783
|
|
| MD5 |
938605b379661feb553e695389929736
|
|
| BLAKE2b-256 |
b5367f6542bef4facb939972f42e53e11abae990c5f0bad52c23ffc2f2c4a277
|
Provenance
The following attestation bundles were made for sievelib-1.4.3-py3-none-any.whl:
Publisher:
sievelib.yml on tonioo/sievelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sievelib-1.4.3-py3-none-any.whl -
Subject digest:
58e6fb446c47166957816b34fc8a8acc912a0bb3f6aa6cc8fd65fc8f16013783 - Sigstore transparency entry: 724638783
- Sigstore integration time:
-
Permalink:
tonioo/sievelib@69f644c9dcc4ce1cb6b0c19d3680491979d3608e -
Branch / Tag:
refs/tags/1.4.3 - Owner: https://github.com/tonioo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sievelib.yml@69f644c9dcc4ce1cb6b0c19d3680491979d3608e -
Trigger Event:
release
-
Statement type: