fix: remove deprecated distutils (#604)

This commit is contained in:
Robert Kaussow 2023-10-16 12:11:13 +02:00 committed by GitHub
parent 7b82bbf871
commit 4988cac525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -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):