diff options
| author | 2019-10-08 11:38:56 +0100 | |
|---|---|---|
| committer | 2019-10-08 11:38:56 +0100 | |
| commit | 68aa89f16f725a47aa0da9d1080b1cce05df7a58 (patch) | |
| tree | b93e29aeb48e0a0330fe76623c0f19033adda4f7 /src | |
| parent | make 'sasl' setting 'sensitive' (diff) | |
| signature | ||
commit FunctionSetting changes i forgot to commit yesterday
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/__init__.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py index e9e7bee5..eaf3cc03 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -356,16 +356,21 @@ class OptionsSetting(Setting): class FunctionSetting(Setting): def __init__(self, func: typing.Callable[[str], bool], name: str, - help: str=None, example: str=None): + help: str=None, example: str=None, format=None): self._func = func Setting.__init__(self, name, help, example) + if not format == None: + self.format = format def parse(self, value: str) -> typing.Any: return self._func(value) +def sensitive_format(value: typing.Any): + return "*"*16 + class SensitiveSetting(Setting): def format(self, value: typing.Any): - return "*"*16 + return sensitive_format(value) class DeadlineExceededException(Exception): pass |
