Skip to content

Commit

Permalink
Remove deprecated distutils
Browse files Browse the repository at this point in the history
  • Loading branch information
AstiaSun committed Feb 19, 2024
1 parent e0d9db3 commit 63e31b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yamx/extra.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# not very supported pieces of functionality

from dataclasses import dataclass
from distutils.util import strtobool
from typing import Any, Dict, Optional, Set

from jinja2 import nodes
Expand All @@ -14,6 +13,7 @@
ConditionalSeq,
)
from yamx.loader.utils import get_jinja_env
from yamx.utils import strtobool


@dataclass(frozen=True)
Expand Down
14 changes: 14 additions & 0 deletions yamx/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def strtobool(val) -> int:
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ("y", "yes", "t", "true", "on", "1"):
return 1
elif val in ("n", "no", "f", "false", "off", "0"):
return 0
else:
raise ValueError("invalid truth value %r" % (val,))

0 comments on commit 63e31b3

Please sign in to comment.