]> www.average.org Git - loctrkd.git/blob - test/__init__.py
Update changelog for 2.00 release
[loctrkd.git] / test / __init__.py
1 from typing import Callable, Tuple
2
3
4 __all__ = ("no_less_than",)
5
6
7 def no_less_than(base: str) -> Callable[[str], bool]:
8     def _no_less_than(base: str, what: str) -> bool:
9         bl, wl = (
10             tuple((int(el) for el in s.split("."))) for s in (base, what)
11         )
12
13         def __no_less_than(bl: Tuple[int, ...], wl: Tuple[int, ...]) -> bool:
14             if len(bl) == 0 and len(wl) == 0:
15                 return True
16             if (len(bl) == 0) != (len(wl) == 0):
17                 return len(bl) < len(wl)
18             # At this point both lists are non-empty
19             if bl[0] == wl[0]:
20                 return __no_less_than(bl[1:], wl[1:])
21             return bl[0] < wl[0]
22
23         return __no_less_than(bl, wl)
24
25     return lambda arg: _no_less_than(base, arg)