conftypes: Better handling of ShellCommand.
This commit is contained in:
parent
5ee5b2f41e
commit
74b45aea47
@ -909,7 +909,7 @@ class WebKitBytesList(List):
|
|||||||
"set!".format(self.length))
|
"set!".format(self.length))
|
||||||
|
|
||||||
|
|
||||||
class ShellCommand(String):
|
class ShellCommand(BaseType):
|
||||||
|
|
||||||
"""A shellcommand which is split via shlex.
|
"""A shellcommand which is split via shlex.
|
||||||
|
|
||||||
@ -920,7 +920,7 @@ class ShellCommand(String):
|
|||||||
typestr = 'shell-command'
|
typestr = 'shell-command'
|
||||||
|
|
||||||
def __init__(self, placeholder=False, none_ok=False):
|
def __init__(self, placeholder=False, none_ok=False):
|
||||||
super().__init__(none_ok=none_ok)
|
super().__init__(none_ok)
|
||||||
self.placeholder = placeholder
|
self.placeholder = placeholder
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
@ -929,9 +929,12 @@ class ShellCommand(String):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise ValidationError(value, "may not be empty!")
|
raise ValidationError(value, "may not be empty!")
|
||||||
super().validate(value)
|
|
||||||
if self.placeholder and '{}' not in self.transform(value):
|
if self.placeholder and '{}' not in self.transform(value):
|
||||||
raise ValidationError(value, "needs to contain a {}-placeholder.")
|
raise ValidationError(value, "needs to contain a {}-placeholder.")
|
||||||
|
try:
|
||||||
|
shlex.split(value)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValidationError(value, str(e))
|
||||||
|
|
||||||
def transform(self, value):
|
def transform(self, value):
|
||||||
if not value:
|
if not value:
|
||||||
|
Loading…
Reference in New Issue
Block a user