diff --git a/devlib/utils/types.py b/devlib/utils/types.py index be30bfc..645328d 100644 --- a/devlib/utils/types.py +++ b/devlib/utils/types.py @@ -68,6 +68,15 @@ def numeric(value): """ if isinstance(value, int): return value + + if isinstance(value, basestring): + value = value.strip() + if value.endswith('%'): + try: + return float(value.rstrip('%')) / 100 + except ValueError: + raise ValueError('Not numeric: {}'.format(value)) + try: fvalue = float(value) except ValueError: