Skip to content

Commit

Permalink
fix: remove deprecated distutils (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Oct 16, 2023
1 parent ab9d0de commit cb5fa84
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion prometheuspvesd/utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit cb5fa84

Please sign in to comment.