X-Git-Url: http://www.average.org/gitweb/?a=blobdiff_plain;f=test%2F__init__.py;fp=test%2F__init__.py;h=b4ddd2ef7a79ad3ad2d8a11ddbc5f5e4285456a4;hb=5c3e8e8f28d8dcb72e9212ddd88f73f4bf71cea2;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=5ef83cb7db7464a5a625b0b7c86c4e25ebbb0de1;p=loctrkd.git diff --git a/test/__init__.py b/test/__init__.py index e69de29..b4ddd2e 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -0,0 +1,25 @@ +from typing import Callable, Tuple + + +__all__ = ("no_less_than",) + + +def no_less_than(base: str) -> Callable[[str], bool]: + def _no_less_than(base: str, what: str) -> bool: + bl, wl = ( + tuple((int(el) for el in s.split("."))) for s in (base, what) + ) + + def __no_less_than(bl: Tuple[int, ...], wl: Tuple[int, ...]) -> bool: + if len(bl) == 0 and len(wl) == 0: + return True + if (len(bl) == 0) != (len(wl) == 0): + return len(bl) < len(wl) + # At this point both lists are non-empty + if bl[0] == wl[0]: + return __no_less_than(bl[1:], wl[1:]) + return bl[0] < wl[0] + + return __no_less_than(bl, wl) + + return lambda arg: _no_less_than(base, arg)