From af6c021337b0278613f92ca382f36c26a1b34656 Mon Sep 17 00:00:00 2001 From: cedric Date: Wed, 29 May 2024 17:07:16 +0200 Subject: [PATCH] remove strtobool, removed in python-3.12 --- component_registry_bindings/helpers.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/component_registry_bindings/helpers.py b/component_registry_bindings/helpers.py index bb88c34..d50024e 100644 --- a/component_registry_bindings/helpers.py +++ b/component_registry_bindings/helpers.py @@ -2,12 +2,32 @@ component-registry-bindings helpers """ import json -from distutils.util import strtobool from os import getenv from typing import Any, Union from .exceptions import ComponentRegistryBindingsException +_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,