From 40f13919ca7c951df46e547db751e8c9faaa9e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sat, 9 Mar 2019 23:07:57 +0100 Subject: [PATCH] Allowed to update/ remove addons by name --- CurseBreaker.py | 4 ++-- CurseBreaker/Core.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CurseBreaker.py b/CurseBreaker.py index 388eef2..0a345fb 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -14,8 +14,8 @@ def __init__(self): epilog='Supported URLs: https://www.curseforge.com/wow/addons/, ' 'https://www.wowinterface.com/downloads/, ElvUI, ElvUI:Dev') parser.add_argument('-a', '--add', help='Install add-ons', metavar='URL') - parser.add_argument('-r', '--remove', help='Remove add-ons', metavar='URL') - parser.add_argument('-u', '--update', help='Update add-ons', metavar='URL') + parser.add_argument('-r', '--remove', help='Remove add-ons', metavar='URL/Name') + parser.add_argument('-u', '--update', help='Update add-ons', metavar='URL/Name') parser.add_argument('-l', '--list', help='Show installed add-ons', action='store_true') self.args = parser.parse_args() diff --git a/CurseBreaker/Core.py b/CurseBreaker/Core.py index 0d7268b..f29d088 100644 --- a/CurseBreaker/Core.py +++ b/CurseBreaker/Core.py @@ -22,7 +22,7 @@ def save(self): def check_if_installed(self, url): for addon in self.config['Addons']: - if addon['URL'] == url: + if addon['URL'] == url or addon['Name'] == url: return addon def cleanup(self, directories): @@ -67,7 +67,8 @@ def del_addon(self, url): old = self.check_if_installed(url) if old: self.cleanup(old['Directories']) - self.config['Addons'][:] = [d for d in self.config['Addons'] if d.get('URL') != url] + self.config['Addons'][:] = [d for d in self.config['Addons'] if d.get('URL') != url + and d.get('Name') != url] self.save() return old['Name'], old['InstalledVersion'] return False, False @@ -75,7 +76,7 @@ def del_addon(self, url): def update_addon(self, url): old = self.check_if_installed(url) if old: - new = self.parse_url(url) + new = self.parse_url(old['URL']) new.get_current_version() oldversion = old['InstalledVersion'] if new.currentVersion != old['InstalledVersion']: