From 8f2d42892bed429ca4a4d55035188b45ad01de1d Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 5 Jan 2022 19:49:08 +0100 Subject: [PATCH] [cli/utils] Remove custom subparser (no longer required) Apparently this was *never* required? I just didn't know? Genuinely I have no idea what made me add this. --- legendary/cli.py | 2 -- legendary/utils/custom_parser.py | 29 ----------------------------- 2 files changed, 31 deletions(-) delete mode 100644 legendary/utils/custom_parser.py diff --git a/legendary/cli.py b/legendary/cli.py index 0435877..5383e48 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -23,7 +23,6 @@ from legendary.models.exceptions import InvalidCredentialsError from legendary.models.game import SaveGameStatus, VerifyResult, Game from legendary.utils.cli import get_boolean_choice, get_int_choice, sdl_prompt, strtobool from legendary.utils.crossover import * -from legendary.utils.custom_parser import AliasedSubParsersAction from legendary.utils.env import is_windows_mac_or_pyi from legendary.utils.eos import add_registry_entries, query_registry_entries, remove_registry_entries from legendary.utils.lfs import validate_files, clean_filename @@ -2351,7 +2350,6 @@ class LegendaryCLI: def main(): parser = argparse.ArgumentParser(description=f'Legendary v{__version__} - "{__codename__}"') - parser.register('action', 'parsers', AliasedSubParsersAction) # general arguments parser.add_argument('-H', '--full-help', dest='full_help', action='store_true', diff --git a/legendary/utils/custom_parser.py b/legendary/utils/custom_parser.py deleted file mode 100644 index 3f74dd7..0000000 --- a/legendary/utils/custom_parser.py +++ /dev/null @@ -1,29 +0,0 @@ -import argparse - -# reference: https://gist.github.com/sampsyo/471779#gistcomment-2886157 - - -class AliasedSubParsersAction(argparse._SubParsersAction): - class _AliasedPseudoAction(argparse.Action): - def __init__(self, name, aliases, help): - dest = name - if aliases: - dest += ' (%s)' % ','.join(aliases) - sup = super(AliasedSubParsersAction._AliasedPseudoAction, self) - sup.__init__(option_strings=[], dest=dest, help=help) - - def add_parser(self, name, **kwargs): - aliases = kwargs.pop('aliases', []) - parser = super(AliasedSubParsersAction, self).add_parser(name, **kwargs) - - # Make the aliases work. - for alias in aliases: - self._name_parser_map[alias] = parser - # Make the help text reflect them, first removing old help entry. - if 'help' in kwargs: - help = kwargs.pop('help') - self._choices_actions.pop() - pseudo_action = self._AliasedPseudoAction(name, aliases, help) - self._choices_actions.append(pseudo_action) - - return parser