MCPcopy
hub / github.com/legendary-gl/legendary / uninstall_game

Method uninstall_game

legendary/cli.py:1149–1183  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

1147 logger.info('Automatic installation not available on Linux.')
1148
1149 def uninstall_game(self, args):
1150 if not self.core.lgd.lock_installed():
1151 logger.fatal('Failed to acquire installed data lock, only one instance of Legendary may '
1152 'install/import/move applications at a time.')
1153 return
1154
1155 args.app_name = self._resolve_aliases(args.app_name)
1156 igame = self.core.get_installed_game(args.app_name)
1157 if not igame:
1158 logger.error(f'Game {args.app_name} not installed, cannot uninstall!')
1159 exit(0)
1160
1161 if not args.yes:
1162 if not get_boolean_choice(f'Do you wish to uninstall "{igame.title}"?', default=False):
1163 print('Aborting...')
1164 exit(0)
1165
1166 if os.name == 'nt' and igame.uninstaller and not args.skip_uninstaller:
1167 self._handle_uninstaller(igame, args.yes)
1168
1169 try:
1170 if not igame.is_dlc:
1171 # Remove DLC first so directory is empty when game uninstall runs
1172 dlcs = self.core.get_dlc_for_game(igame.app_name)
1173 for dlc in dlcs:
1174 if (idlc := self.core.get_installed_game(dlc.app_name)) is not None:
1175 logger.info(f'Uninstalling DLC "{dlc.app_name}"...')
1176 self.core.uninstall_game(idlc, delete_files=not args.keep_files)
1177
1178 logger.info(f'Removing "{igame.title}" from "{igame.install_path}"...')
1179 self.core.uninstall_game(igame, delete_files=not args.keep_files,
1180 delete_root_directory=not igame.is_dlc)
1181 logger.info('Game has been uninstalled.')
1182 except Exception as e:
1183 logger.warning(f'Removing game failed: {e!r}, please remove {igame.install_path} manually.')
1184
1185 def _handle_uninstaller(self, igame, yes=False):
1186 uninstaller = igame.uninstaller

Callers 1

mainFunction · 0.95

Calls 7

_resolve_aliasesMethod · 0.95
_handle_uninstallerMethod · 0.95
get_boolean_choiceFunction · 0.90
lock_installedMethod · 0.80
get_dlc_for_gameMethod · 0.80
infoMethod · 0.80
get_installed_gameMethod · 0.45

Tested by

no test coverage detected