def uk_annas_quest(): return UninstallKey( key_name="Anna's Quest_is1", display_name="Anna's Quest", uninstall_string="\"D:\\Games\\Anna's Quest\\unins000.exe\"", install_location="D:\\Games\\Anna's Quest\\", )
def uk_windosill(): return UninstallKey( key_name="Windosill_is1", display_name= "Windosill version 1.61", uninstall_string="\"C:\\Games\\The Windosill\\uninstall.exe\"", install_location="C:\\Games\\The Windosill\\" )
def test_no_match(): human_name = "Orks: final cutdown" uk = UninstallKey( 'keyname', 'displayname', 'uninstall_str', install_location='somewhere\\else', ) assert False == WindowsAppFinder._matches(human_name, uk)
def test_match_colon_in_name(): human_name = "Orks: final cutdown" install_location = "C:\\Games\\Orks Final Cutdown" uk = UninstallKey( key_name="mock", display_name="Orks Final Cutdown", uninstall_string="mock", install_location=install_location, ) assert True == WindowsAppFinder._matches(human_name, uk)
def test_match_with_folder_name(): human_name = "The Windosill" install_location = 'C:\\Games\\The Windosill\\' uk = UninstallKey( key_name="Windosill_is1", display_name="Windosill version 1.61", uninstall_string="\"C:\\Games\\The Windosill\\uninstall.exe\"", install_location=install_location, ) assert True == WindowsAppFinder._matches(human_name, uk)
def test_uk_uninstall_string_path(): expected = pathlib.Path(R"D:\Games\HoMM 3 Complete\unins000.exe") uninstall_strings = [ R'D:\Games\HoMM 3 Complete\unins000.exe', R'"D:\Games\HoMM 3 Complete\unins000.exe"', R'"D:\Games\HoMM 3 Complete\unins000.exe" /SILENT', R'"D:\Games\HoMM 3 Complete\unins000.exe" uninstall extra_path "C:\ProgramData\HoMM\saves"' R'"D:\Games\HoMM 3 Complete\unins000.exe" --lang=esMX, --display-name="Heroes 3"' ] for i in uninstall_strings: uk = UninstallKey('', '', uninstall_string=i) assert expected == uk.uninstall_string_path
async def test_find_game_display_uninstall(mock_winreg_watcher): """Find exe based on DisplayIcon subkey but not if it is uninstaller""" human_name, machine_name = "Agame", 'agame' uninstall = "C:\\agame\\uninstall.exe" uk_game = UninstallKey(key_name=human_name, display_name=human_name, uninstall_string=uninstall, display_icon=uninstall) owned_games = {human_name: machine_name} finder = WindowsAppFinder() finder._reg = mock_winreg_watcher(uninstall_keys=[uk_game]) assert {} == await finder(owned_games)
def uk_torchlight2(): """In this real example, there is no installLocation and displayIcon links to launcher executable. """ return UninstallKey( key_name="{049FF5E4-EB02-4c42-8DB0-226E2F7A9E53}", display_name="Torchlight 2", uninstall_string= R"C:\Users\Public\Games\Runic Games\Torchlight 2\uninstall.exe", install_location=None, display_icon= R"C:\Users\Public\Games\Runic Games\Torchlight 2\ModLauncher.exe", )
def _matches(human_name: str, uk: UninstallKey) -> bool: def escape(x): return x.replace(':', '').lower() def escaped_matches(a, b): return escape(a) == escape(b) def norm(x): return x.replace(" III", " 3").replace(" II", " 2") if human_name == uk.display_name \ or escaped_matches(human_name, uk.display_name) \ or uk.key_name.lower().startswith(human_name.lower()): return True location = uk.get_install_location() if location: if escaped_matches(human_name, location.name): return True # quickfix for Torchlight II ect., until better solution will be provided return escaped_matches(norm(human_name), norm(uk.display_name))
def test_uk_uninstall_string_path_msi(): """No support for msi uninstallers for now""" path = 'MsiExec.exe /I{20888FA1-8127-42E3-969F-9BF93245AC83}' uk = UninstallKey('', '', uninstall_string=path) assert None == uk.uninstall_string_path
def test_uk_uninstall_string_path_empty(): assert None == UninstallKey('', '', uninstall_string='').uninstall_string_path
def test_uk_display_icon_path(): display_icons = ["\"C:\\abc\\s.ico\",0", "C:\\abc\\s.ico,1", "C:\\abc\\s.ico", "\"C:\\abc\\s.ico\""] for i in display_icons: uk = UninstallKey('', '', '', display_icon=i) assert pathlib.Path("C:\\abc\\s.ico") == uk.display_icon_path
def test_match_by_key_name(): uk = UninstallKey('Limbo', '', uninstall_string='') human_name = 'LIMBO' assert True == WindowsAppFinder._matches(human_name, uk)