diff options
Diffstat (limited to 'libpathod/utils.py')
-rw-r--r-- | libpathod/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libpathod/utils.py b/libpathod/utils.py index 70a97cff..26e9427d 100644 --- a/libpathod/utils.py +++ b/libpathod/utils.py @@ -8,6 +8,19 @@ SIZE_UNITS = dict( t = 1024**4, ) + +class MemBool: + """ + Truth-checking with a memory, for use in chained if statements. + """ + def __init__(self): + self.v = None + + def __call__(self, v): + self.v = v + return bool(v) + + def parse_size(s): try: return int(s) |