From 06f6e4839b203e7e445a7982e327970b6b447253 Mon Sep 17 00:00:00 2001 From: Jason Shepherd Date: Mon, 27 May 2024 13:50:23 +1000 Subject: [PATCH] remove deprecated dependency on distutils --- osidb_bindings/helpers.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/osidb_bindings/helpers.py b/osidb_bindings/helpers.py index aef5b09..23b4a1e 100644 --- a/osidb_bindings/helpers.py +++ b/osidb_bindings/helpers.py @@ -2,12 +2,33 @@ osidb-registry-bindings helpers """ import json -from distutils.util import strtobool from os import getenv from typing import Any, Union from .exceptions import OSIDBBindingsException +_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, +} + + +def strtobool(value): + try: + return _MAP[str(value).lower()] + except KeyError: + raise ValueError('"{}" is not a valid bool value'.format(value)) + def get_env( key: str,