diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 481b1255a11161055485ed7118b5b65a3069d4df..0b3ab54531e9513a31faf985422c44e986af9f7b 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -154,6 +154,13 @@ def _TDict(val): return isinstance(val, dict) +def _TIsLength(size): + """Check is the given container is of the given size. + + """ + return lambda container: len(container) == size + + # Combinator types def _TAnd(*args): """Combine multiple functions using an AND operation. @@ -173,6 +180,13 @@ def _TOr(*args): return fn +def _TMap(fn, test): + """Checks that a modified version of the argument passes the given test. + + """ + return lambda val: test(fn(val)) + + # Type aliases #: a non-empty string