Skip to content

Commit

Permalink
Added option to ignore dependencies (close #262)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Dec 17, 2020
1 parent 300e7db commit a74b7af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def init_config(self):
else:
self.config = {'Addons': [],
'IgnoreClientVersion': {},
'IgnoreDependencies': {},
'Backup': {'Enabled': True, 'Number': 7},
'CFCacheCloudFlare': {},
'Version': __version__,
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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):
Expand All @@ -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()
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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))
Expand Down

0 comments on commit a74b7af

Please sign in to comment.