summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-18 21:31:41 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-18 21:31:41 (GMT)
commit3c380daedab669f2a7863812a06b218ae00959c5 (patch)
tree14cda549bc6938e428a4cc9ebe19f74337e066b0
parent86716afa17c3ddc5148efedc29ed7e15af0ba524 (diff)
downloadpython-sievelib-3c380daedab669f2a7863812a06b218ae00959c5.tar.gz
Take into account extra_args may contain strings as well
Stringify values we're writing out (they may be integers, you know) Make sure we progress to the next argument Set curarg when we have extra_arg
-rw-r--r--sievelib/commands.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/sievelib/commands.py b/sievelib/commands.py
index 41d2c26..95a424f 100644
--- a/sievelib/commands.py
+++ b/sievelib/commands.py
@@ -165,8 +165,10 @@ class Command(object):
if "string" in arg["type"]:
target.write('"%s"' % value.strip('"'))
+ elif arg.has_key('extra_arg') and "string" in arg['extra_arg']['type']:
+ target.write('"%s"' % value.strip('"'))
else:
- target.write(value)
+ target.write("%s" % value)
if not self.accept_children:
if self.get_type() != "test":
@@ -351,6 +353,7 @@ class Command(object):
if not self.has_arguments():
return False
+
if self.iscomplete():
return False
@@ -360,13 +363,18 @@ class Command(object):
avalue in self.curarg["extra_arg"]["values"]:
if add:
self.arguments[self.curarg["name"]] = avalue
+ self.nextargpos += 1
self.curarg = None
return True
+
raise BadValue(self.curarg["name"], avalue)
failed = False
for arg in self.args_definition[self.nextargpos:]:
+ if self.arguments.has_key(arg["name"]):
+ continue
+
if arg["required"]:
if arg["type"] == ["testlist"]:
if not atype == "test":
@@ -383,15 +391,14 @@ class Command(object):
self.nextargpos += 1
if add:
self.arguments[arg["name"]] = avalue
- self.nextargpos += 1
break
- if self.arguments.has_key(arg["name"]):
- continue
-
if self.__is_valid_value_for_arg(arg, avalue):
self.arguments[arg["name"]] = avalue
+ if arg.has_key('extra_arg'):
+ self.curarg = arg
+ break
self.nextargpos += 1
break
@@ -654,18 +661,18 @@ class SizeCommand(TestCommand):
class VacationCommand(ActionCommand):
args_definition = [
- {"name": "subject",
- "type": [ "tag" ],
- "write_tag": True,
- "values": [ ":subject" ],
- "extra_arg": {"type": "string"},
- "required": False},
{"name": "days",
"type": [ "tag" ],
"write_tag": True,
"values": [ ":days" ],
"extra_arg": {"type": "number"},
"required": False},
+ {"name": "subject",
+ "type": [ "tag" ],
+ "write_tag": True,
+ "values": [ ":subject" ],
+ "extra_arg": {"type": "string"},
+ "required": False},
{"name": "from",
"type": [ "tag" ],
"write_tag": True,