diff options
| author | 2019-06-14 12:01:55 +0100 | |
|---|---|---|
| committer | 2019-06-14 12:01:55 +0100 | |
| commit | f05fc209b015e9d883566fc8cc4141dc9eff4db3 (patch) | |
| tree | 599c4bb8f31e22af304c3b8f20977738b9b55649 /src | |
| parent | Catch `yield`s in command callbacks for e.g. permission checks (diff) | |
| signature | ||
Add a way to __or__ `utils.Check`s, as a "if one of these passes" thing
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/__init__.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 869690ff..c0acee4d 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -185,10 +185,19 @@ def export(setting: str, value: typing.Any): return module return _export_func +class MultiCheck(object): + def __init__(self, + requests: typing.List[typing.Tuple[str, typing.List[str]]]): + self.requests = requests class Check(object): def __init__(self, request: str, *args: typing.List[str]): self.request = request self.args = args + def to_multi(self): + return MultiCheck([(self.request, self.args)]) + def __or__(self, other: "Check"): + return MultiCheck([(self.request, self.args), + (other.request, other.args)]) TOP_10_CALLABLE = typing.Callable[[typing.Any], typing.Any] def top_10(items: typing.Dict[typing.Any, typing.Any], |
