From 0c8398e4a6c63835fef1402457c7a27cc5c8c001 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 17 May 2016 15:28:36 +0200 Subject: [PATCH] add PasswordOption --- tiramisu/option/__init__.py | 4 ++-- tiramisu/option/option.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tiramisu/option/__init__.py b/tiramisu/option/__init__.py index 76c3446..9084465 100644 --- a/tiramisu/option/__init__.py +++ b/tiramisu/option/__init__.py @@ -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') diff --git a/tiramisu/option/option.py b/tiramisu/option/option.py index 06b0b83..66f0290 100644 --- a/tiramisu/option/option.py +++ b/tiramisu/option/option.py @@ -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()