From ec56049c0f5b49bc4c5bcf0acb7fea89ec1c1df4 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 29 May 2024 01:03:03 +0200 Subject: [PATCH] Replace distutils usage in amcrest.utils Closes: #234 --- src/amcrest/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/amcrest/utils.py b/src/amcrest/utils.py index c01b195..f8807a8 100644 --- a/src/amcrest/utils.py +++ b/src/amcrest/utils.py @@ -14,7 +14,6 @@ from typing import List # pylint: disable=no-name-in-module -from distutils import util from typing import List, Tuple, Union DATEFMT = "%Y-%m-%d %H:%M:%S" @@ -53,7 +52,13 @@ def str2bool(value: Union[str, int]) -> bool: False values: n, no, false, off, 0 """ if isinstance(value, str): - return bool(util.strtobool(value)) + value = value.lower() + if value in ["y", "yes", "true", "t", "on", "1"]: + return True + elif value in ["n", "no", "false", "off", "0"]: + return False + else: + raise ValueError return bool(value)