add PasswordOption
authorEmmanuel Garette <egarette@cadoles.com>
Tue, 17 May 2016 13:28:36 +0000 (15:28 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Tue, 17 May 2016 13:28:36 +0000 (15:28 +0200)
tiramisu/option/__init__.py
tiramisu/option/option.py

index 76c3446..9084465 100644 (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')
index 06b0b83..66f0290 100644 (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()