From a74b7af46f9f4c1a054b8adc620afa62798d1605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 17 Dec 2020 12:03:51 +0100 Subject: [PATCH] Added option to ignore dependencies (close #262) --- CB/Core.py | 13 ++++++++++--- CurseBreaker.py | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CB/Core.py b/CB/Core.py index 4b9e1ac..dfc47e7 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -66,6 +66,7 @@ def init_config(self): else: self.config = {'Addons': [], 'IgnoreClientVersion': {}, + 'IgnoreDependencies': {}, 'Backup': {'Enabled': True, 'Number': 7}, 'CFCacheCloudFlare': {}, 'Version': __version__, @@ -124,7 +125,8 @@ def update_config(self): ['3.1.10', 'CFCacheCloudFlare', {}], ['3.7.0', 'CompactMode', False], ['3.10.0', 'AutoUpdate', True], - ['3.12.0', 'ShowAuthors', True]]: + ['3.12.0', 'ShowAuthors', True], + ['3.16.0', 'IgnoreDependencies', {}]]: if add[1] not in self.config.keys(): self.config[add[1]] = add[2] for delete in [['1.3.0', 'URLCache'], @@ -248,7 +250,7 @@ def parse_url_source(self, url): else: return '?', None - def add_addon(self, url, ignore): + def add_addon(self, url, ignore, nodeps): if url.endswith(':'): raise NotImplementedError('Provided URL is not supported.') elif 'twitch://' in url: @@ -271,6 +273,8 @@ def add_addon(self, url, ignore): if not addon: if ignore: self.config['IgnoreClientVersion'][url] = True + if nodeps: + self.config['IgnoreDependencies'][url] = True new = self.parse_url(url) new.get_addon() addon = self.check_if_installed_dirs(new.directories) @@ -288,7 +292,8 @@ def add_addon(self, url, ignore): 'Checksums': checksums }) self.save_config() - return True, new.name, new.currentVersion, new.dependencies + return True, new.name, new.currentVersion, \ + None if url in self.config['IgnoreDependencies'].keys() else new.dependencies return False, addon['Name'], addon['Version'], None def del_addon(self, url, keep): @@ -297,6 +302,7 @@ def del_addon(self, url, keep): if not keep: self.cleanup(old['Directories']) self.config['IgnoreClientVersion'].pop(old['URL'], None) + self.config['IgnoreDependencies'].pop(old['URL'], None) self.config['Addons'][:] = [d for d in self.config['Addons'] if d.get('URL') != url and d.get('Name') != url] self.save_config() @@ -316,6 +322,7 @@ def update_addon(self, url, update, force): modified = self.check_checksum(old, False) blocked = self.check_if_blocked(old) if force or (new.currentVersion != old['Version'] and update and not modified and not blocked): + new.dependencies = None if url in self.config['IgnoreDependencies'].keys() else new.dependencies new.get_addon() self.cleanup(old['Directories']) new.install(self.path) diff --git a/CurseBreaker.py b/CurseBreaker.py index ce93ad4..8226336 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -402,10 +402,14 @@ def parse_link(self, text, link, dev=None, authors=None, uiversion=None): def c_install(self, args, recursion=False): if args: optignore = False + optnodeps = False pargs = split(args.replace("'", "\\'")) if '-i' in pargs: optignore = True args = args.replace('-i', '', 1) + if '-d' in pargs: + optnodeps = True + args = args.replace('-d', '', 1) dependencies = DependenciesParser(self.core) args = re.sub(r'([a-zA-Z0-9_:])([ ]+)([a-zA-Z0-9_:])', r'\1,\3', args) addons = [addon.strip() for addon in list(reader([args], skipinitialspace=True))[0]] @@ -416,7 +420,7 @@ def c_install(self, args, recursion=False): while not progress.finished: for addon in addons: try: - installed, name, version, deps = self.core.add_addon(addon, optignore) + installed, name, version, deps = self.core.add_addon(addon, optignore, optnodeps) if installed: self.table.add_row('[green]Installed[/green]', Text(name, no_wrap=True), Text(version, no_wrap=True))