add PasswordOption

This commit is contained in:
Emmanuel Garette 2016-05-17 15:28:36 +02:00
parent d1c9250e34
commit 0c8398e4a6
2 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from .option import (ChoiceOption, BoolOption, IntOption, FloatOption,
StrOption, UnicodeOption, IPOption, PortOption,
NetworkOption, NetmaskOption, BroadcastOption,
DomainnameOption, EmailOption, URLOption, UsernameOption,
FilenameOption)
FilenameOption, PasswordOption)
__all__ = ('MasterSlaves', 'OptionDescription', 'DynOptionDescription',
@ -15,4 +15,4 @@ __all__ = ('MasterSlaves', 'OptionDescription', 'DynOptionDescription',
'IntOption', 'FloatOption', 'StrOption', 'UnicodeOption',
'IPOption', 'PortOption', 'NetworkOption', 'NetmaskOption',
'BroadcastOption', 'DomainnameOption', 'EmailOption', 'URLOption',
'UsernameOption', 'FilenameOption', 'submulti')
'UsernameOption', 'FilenameOption', 'PasswordOption', 'submulti')

View File

@ -162,6 +162,17 @@ else:
return ValueError(_('invalid unicode')) # pragma: optional cover
class PasswordOption(Option):
"represents the choice of a password"
__slots__ = tuple()
def _validate(self, value, context=undefined, current_opt=undefined,
returns_raise=False):
err = self._impl_valid_unicode(value)
if err:
return err
class IPOption(Option):
"represents the choice of an ip"
__slots__ = tuple()