From 0bd61092a8af05bfbed9be453ca4eefab3bd1538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sat, 17 Oct 2020 19:03:08 +0200 Subject: [PATCH] Added warning about outdated project (close #176) --- CB/Core.py | 8 +++++--- CB/CurseForge.py | 3 +++ CB/GitHub.py | 1 + CB/GitLab.py | 1 + CB/Tukui.py | 1 + CB/WoWInterface.py | 1 + CurseBreaker.py | 29 ++++++++++++++++++----------- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/CB/Core.py b/CB/Core.py index 58930dc..7579b75 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -35,6 +35,8 @@ def __init__(self): self.cachePath = Path('WTF/CurseBreaker.cache') self.clientType = 'wow_retail' self.wagoCompanionVersion = 1110 + self.currentRetailVersion = '9.0.1' + self.currentClassicVersion = '1.13.5' self.config = None self.cfIDs = None self.dirIndex = None @@ -313,9 +315,9 @@ def update_addon(self, url, update, force): if force: modified = False blocked = False - return new.name, new.author, new.currentVersion, oldversion, modified, blocked, source, sourceurl,\ - new.changelogUrl, new.dependencies, dev - return url, [], False, False, False, False, '?', None, None, None, None + return new.name, new.author, new.currentVersion, oldversion, new.uiVersion, modified, blocked, source, \ + sourceurl, new.changelogUrl, new.dependencies, dev + return url, [], False, False, None, False, False, '?', None, None, None, None def check_checksum(self, addon, bulk=True): checksums = {} diff --git a/CB/CurseForge.py b/CB/CurseForge.py index ceb3364..a3351e5 100644 --- a/CB/CurseForge.py +++ b/CB/CurseForge.py @@ -35,6 +35,7 @@ def __init__(self, url, project, checkcache, clienttype, allowdev): self.downloadUrl = None self.changelogUrl = None self.currentVersion = None + self.uiVersion = None self.archive = None self.dependencies = None self.directories = [] @@ -59,6 +60,8 @@ def get_current_version(self): self.downloadUrl = f['downloadUrl'] self.changelogUrl = f'{self.payload["websiteUrl"]}/files/{f["id"]}' self.currentVersion = f['displayName'] + if len(f['gameVersion']) > 0: + self.uiVersion = max(f['gameVersion']) if len(f['dependencies']) > 0: self.dependencies = [] for d in f['dependencies']: diff --git a/CB/GitHub.py b/CB/GitHub.py index a220581..815a984 100644 --- a/CB/GitHub.py +++ b/CB/GitHub.py @@ -24,6 +24,7 @@ def __init__(self, url, clienttype): self.name = project.split('/')[1] self.clientType = clienttype self.currentVersion = self.payload['tag_name'] or self.payload['name'] + self.uiVersion = None self.downloadUrl = None self.changelogUrl = self.payload['html_url'] self.archive = None diff --git a/CB/GitLab.py b/CB/GitLab.py index 5d4b624..d240548 100644 --- a/CB/GitLab.py +++ b/CB/GitLab.py @@ -19,6 +19,7 @@ def __init__(self, name, projectid, path, branch): self.downloadUrl = f'https://git.tukui.org/{path}/-/archive/{branch}/{self.shorthPath}-{branch}.zip' self.changelogUrl = None self.currentVersion = self.payload['commit']['short_id'] + self.uiVersion = None self.branch = branch self.archive = None self.dependencies = None diff --git a/CB/Tukui.py b/CB/Tukui.py index 16f2053..b18af95 100644 --- a/CB/Tukui.py +++ b/CB/Tukui.py @@ -19,6 +19,7 @@ def __init__(self, url, isclassic): self.name = self.payload['name'].strip().strip('\u200b') self.downloadUrl = self.payload['url'] self.currentVersion = self.payload['version'] + self.uiVersion = self.payload['patch'] self.archive = None self.dependencies = None self.directories = [] diff --git a/CB/WoWInterface.py b/CB/WoWInterface.py index 7e7b7de..6e87886 100644 --- a/CB/WoWInterface.py +++ b/CB/WoWInterface.py @@ -24,6 +24,7 @@ def __init__(self, url, checkcache): self.downloadUrl = self.payload['UIDownload'] self.changelogUrl = f'{url}#changelog' self.currentVersion = self.payload['UIVersion'] + self.uiVersion = None self.archive = None self.dependencies = None self.directories = [] diff --git a/CurseBreaker.py b/CurseBreaker.py index bb3c2ce..294f2e1 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -349,7 +349,7 @@ def parse_args(self, args): args = args.replace(addon['Name'], '', 1) return sorted(parsed) - def parse_link(self, text, link, dev=None, authors=None): + def parse_link(self, text, link, dev=None, authors=None, uiversion=None): if dev == 1: dev = ' [bold][B][/bold]' elif dev == 2: @@ -361,10 +361,14 @@ def parse_link(self, text, link, dev=None, authors=None): authors = f' [bold black]by {", ".join(authors)}[/bold black]' else: authors = '' + if uiversion and uiversion not in [self.core.currentRetailVersion, self.core.currentClassicVersion]: + uiversion = ' [bold yellow][!][bold yellow]' + else: + uiversion = '' if link: - obj = Text.from_markup(f'[link={link}]{text}[/link]{dev}{authors}') + obj = Text.from_markup(f'[link={link}]{text}[/link]{dev}{authors}{uiversion}') else: - obj = Text.from_markup(f'{text}{dev}{authors}') + obj = Text.from_markup(f'{text}{dev}{authors}{uiversion}') obj.no_wrap = True return obj @@ -460,9 +464,9 @@ def c_update(self, args, addline=False, update=True, force=False, provider=False while not progress.finished: for addon in addons: try: - name, authors, versionnew, versionold, modified, blocked, source, sourceurl, changelog, deps,\ - dstate = self.core.update_addon(addon if isinstance(addon, str) else addon['URL'], - update, force) + name, authors, versionnew, versionold, uiversion, modified, blocked, source, sourceurl,\ + changelog, deps, dstate = self.core.update_addon( + addon if isinstance(addon, str) else addon['URL'], update, force) dependencies.add_dependency(deps) if provider: source = f' [bold white]{source}[/bold white]' @@ -473,21 +477,24 @@ def c_update(self, args, addline=False, update=True, force=False, provider=False if modified: self.table.add_row(f'[bold red]Modified[/bold red]{source}', self.parse_link(name, sourceurl, authors=authors), - self.parse_link(versionold, changelog, dstate)) + self.parse_link(versionold, changelog, dstate, + uiversion=uiversion)) else: if self.core.config['CompactMode'] and compacted > -1: compacted += 1 else: self.table.add_row(f'[green]Up-to-date[/green]{source}', self.parse_link(name, sourceurl, authors=authors), - self.parse_link(versionold, changelog, dstate)) + self.parse_link(versionold, changelog, dstate, + uiversion=uiversion)) else: if modified or blocked: self.table.add_row(f'[bold red]Update suppressed[/bold red]{source}', self.parse_link(name, sourceurl, authors=authors), - self.parse_link(versionold, changelog, dstate)) + self.parse_link(versionold, changelog, dstate, + uiversion=uiversion)) else: - version = self.parse_link(versionnew, changelog, dstate) + version = self.parse_link(versionnew, changelog, dstate, uiversion=uiversion) version.stylize('yellow') self.table.add_row( f'[yellow]{"Updated" if update else "Update available"}[/yellow]{source}', @@ -667,7 +674,7 @@ def c_show(self, args): self.core.bulk_check(addons) for addon in addons: dependencies = DependenciesParser(self.core) - name, _, _, _, _, _, _, _, _, deps, _ = self.core.update_addon(addon['URL'], False, False) + name, _, _, _, _, _, _, _, _, _, deps, _ = self.core.update_addon(addon['URL'], False, False) dependencies.add_dependency(deps) deps = dependencies.parse_dependency(output=True) if len(deps) > 0: