aboutsummaryrefslogtreecommitdiff
path: root/src/utils/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/__init__.py')
-rw-r--r--src/utils/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index 6c1b90b0..cabfff31 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -344,6 +344,15 @@ class OptionsSetting(Setting):
options_str = ["'%s'" % option for option in options]
return "Options: %s" % ", ".join(options_str)
+class FunctionSetting(Setting):
+ def __init__(self, func: typing.Callable[[str], bool], name: str,
+ help: str=None, example: str=None):
+ self._func = func
+ Setting.__init__(self, name, help, example)
+
+ def parse(self, value: str) -> typing.Any:
+ return self._func(value)
+
class DeadlineExceededException(Exception):
pass
def _raise_deadline():