diff --git a/prometheuspvesd/utils.py b/prometheuspvesd/utils.py index 79fa804..0f233c5 100644 --- a/prometheuspvesd/utils.py +++ b/prometheuspvesd/utils.py @@ -1,7 +1,29 @@ #!/usr/bin/env python3 """Global utility methods and classes.""" -from distutils.util import strtobool + +def strtobool(value): + """Convert a string representation of truth to true or false.""" + + _map = { + "y": True, + "yes": True, + "t": True, + "true": True, + "on": True, + "1": True, + "n": False, + "no": False, + "f": False, + "false": False, + "off": False, + "0": False + } + + try: + return _map[str(value).lower()] + except KeyError as err: + raise ValueError(f'"{value}" is not a valid bool value') from err def to_bool(string):