Skip to content

Commit

Permalink
Getting rid of distutils.
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon committed Mar 23, 2024
1 parent c7a7ec7 commit 700de5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/downloader/ini_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (c) 2021-2022 José Manuel Barroso Galindo <[email protected]>
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
Expand All @@ -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):
Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/downloader/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit 700de5b

Please sign in to comment.