diff --git a/legendary/cli.py b/legendary/cli.py index 8ac9741..4b3c46f 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -12,7 +12,6 @@ import time import webbrowser from collections import defaultdict, namedtuple -from distutils.util import strtobool from logging.handlers import QueueListener from multiprocessing import freeze_support, Queue as MPQueue from platform import platform @@ -22,7 +21,7 @@ from legendary import __version__, __codename__ from legendary.core import LegendaryCore from legendary.models.exceptions import InvalidCredentialsError from legendary.models.game import SaveGameStatus, VerifyResult, Game -from legendary.utils.cli import get_boolean_choice, sdl_prompt +from legendary.utils.cli import get_boolean_choice, sdl_prompt, strtobool from legendary.utils.custom_parser import AliasedSubParsersAction from legendary.utils.env import is_windows_mac_or_pyi from legendary.utils.lfs import validate_files diff --git a/legendary/models/egl.py b/legendary/models/egl.py index f793420..94ff3ac 100644 --- a/legendary/models/egl.py +++ b/legendary/models/egl.py @@ -1,7 +1,7 @@ from copy import deepcopy -from distutils.util import strtobool from legendary.models.game import InstalledGame, Game +from legendary.utils.cli import strtobool _template = { diff --git a/legendary/utils/cli.py b/legendary/utils/cli.py index b470491..c99bda7 100644 --- a/legendary/utils/cli.py +++ b/legendary/utils/cli.py @@ -40,3 +40,22 @@ def sdl_prompt(sdl_data, title): print('Invalid tag:', c) return tags + + +def strtobool(val): + """Convert a string representation of truth to true (1) or false (0). + + True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values + are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if + 'val' is anything else. + + Copied from python standard library as distutils.util.strtobool is deprecated. + """ + 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,)) +