From 68aa89f16f725a47aa0da9d1080b1cce05df7a58 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 8 Oct 2019 11:38:56 +0100 Subject: [PATCH] commit FunctionSetting changes i forgot to commit yesterday --- src/utils/__init__.py | 9 +++++++-- 1 file 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