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 c08b81c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/downloader/ini_parser.py
Expand Up @@ -16,9 +16,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 +28,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 Expand Up @@ -65,3 +62,13 @@ def to_int(n, default):
if isinstance(default, Exception):
raise default
return default


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,))

0 comments on commit c08b81c

Please sign in to comment.