From 700de5be9a179cdc8d36d7717bf8b12641cda1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Barroso=20Galindo?= Date: Sat, 23 Mar 2024 21:50:04 +0100 Subject: [PATCH] Getting rid of distutils. --- src/downloader/ini_parser.py | 7 +++---- src/downloader/other.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/downloader/ini_parser.py b/src/downloader/ini_parser.py index 5fa247e3..f0e763e2 100644 --- a/src/downloader/ini_parser.py +++ b/src/downloader/ini_parser.py @@ -1,4 +1,6 @@ # Copyright (c) 2021-2022 José Manuel Barroso Galindo +from src.downloader.other import strtobool + # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,9 +18,6 @@ # You can download the latest version of this tool from: # https://github.com/MiSTer-devel/Downloader_MiSTer -import distutils -import distutils.util - class IniParser: def __init__(self, ini_args): @@ -31,7 +30,7 @@ def get_string(self, key, default): return self._ini_args.get(key, default).strip('"\' ') def get_bool(self, key, default): - return bool(distutils.util.strtobool(self.get_string(key, 'true' if default else 'false'))) + return bool(strtobool(self.get_string(key, 'true' if default else 'false'))) def get_int(self, key, default): result = self.get_string(key, None) diff --git a/src/downloader/other.py b/src/downloader/other.py index 03a1ce29..b9afdae2 100644 --- a/src/downloader/other.py +++ b/src/downloader/other.py @@ -56,6 +56,16 @@ class UnreachableException(Exception): pass +def strtobool(val: str): + 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,)) + + def format_files_message(file_list): any_mra_files = [file for file in file_list if file[-4:].lower() == '.mra']