summaryrefslogtreecommitdiff
path: root/sievelib
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-20 14:32:45 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-20 14:32:45 (GMT)
commit8642def968511c1b08f389d5eb351cc3fcea3274 (patch)
treed2551b88dca874cc01428f219d91184d111407da /sievelib
parent3c380daedab669f2a7863812a06b218ae00959c5 (diff)
downloadpython-sievelib-8642def968511c1b08f389d5eb351cc3fcea3274.tar.gz
Add support for an if not command clause.
Add support for envelope, and a header clause prefix
Diffstat (limited to 'sievelib')
-rw-r--r--sievelib/factory.py47
1 files changed, 43 insertions, 4 deletions
diff --git a/sievelib/factory.py b/sievelib/factory.py
index f4e4bee..214abc7 100644
--- a/sievelib/factory.py
+++ b/sievelib/factory.py
@@ -102,6 +102,12 @@ class FiltersSet(object):
ifcontrol = get_command_instance("if")
mtypeobj = get_command_instance(matchtype, ifcontrol)
for c in conditions:
+ _cmd = None
+
+ if c[0] == "not":
+ _cmd = get_command_instance(c[0], ifcontrol)
+ c = c[1]
+
if c[0] in ["true", "false"]:
cmd = get_command_instance(c[0], ifcontrol)
elif c in ["true", "false"]:
@@ -110,12 +116,45 @@ class FiltersSet(object):
cmd = get_command_instance("size", ifcontrol)
cmd.check_next_arg("tag", c[1])
cmd.check_next_arg("number", c[2])
+ elif c[0] == "envelope":
+ cmd = get_command_instance("envelope", ifcontrol)
+ for param in c[1:]:
+ try:
+ cmd.check_next_arg("tag", param)
+ except:
+ try:
+ cmd.check_next_arg("string", param)
+ except:
+ try:
+ cmd.check_next_arg("stringlist", param)
+ except:
+ pass
+
else:
cmd = get_command_instance("header", ifcontrol)
- cmd.check_next_arg("tag", c[1])
- cmd.check_next_arg("string", c[0])
- cmd.check_next_arg("string", c[2])
- mtypeobj.check_next_arg("test", cmd)
+ if c[0] == "header":
+ params = c[1:]
+ else:
+ params = c
+
+ for param in params:
+ try:
+ cmd.check_next_arg("tag", param)
+ except:
+ try:
+ cmd.check_next_arg("string", param)
+ except:
+ try:
+ cmd.check_next_arg("stringlist", param)
+ except:
+ pass
+
+ if not _cmd == None:
+ _cmd.check_next_arg("test", cmd)
+ mtypeobj.check_next_arg("test", _cmd)
+ else:
+ mtypeobj.check_next_arg("test", cmd)
+
ifcontrol.check_next_arg("test", mtypeobj)
for actdef in actions: