From 16a54b4afdc5c73d8f1c8fc2d65f419db9599e12 Mon Sep 17 00:00:00 2001 From: Predeactor Date: Mon, 22 Jun 2020 16:25:27 +0000 Subject: [PATCH 01/28] Downloader's plurial & Fix --- redbot/cogs/downloader/downloader.py | 243 ++++++++++++++++++++------- 1 file changed, 182 insertions(+), 61 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 886074b80..0561f4d0a 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -556,9 +556,15 @@ class Downloader(commands.Cog): """List all installed repos.""" repos = self._repo_manager.repos sorted_repos = sorted(repos, key=lambda r: str.lower(r.name)) - joined = _("Installed Repos:\n\n") - for repo in sorted_repos: - joined += "+ {}: {}\n".format(repo.name, repo.short or "") + if len(repos) == 0: + joined = _("There is no repo installed.") + else: + if len(repos) > 1: + joined = _("Installed Repos:\n\n") + else: + joined = _("Installed Repo:\n\n") + for repo in sorted_repos: + joined += "+ {}: {}\n".format(repo.name, repo.short or "") for page in pagify(joined, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) @@ -799,20 +805,37 @@ class Downloader(commands.Cog): message = "" if uninstalled_cogs: - message += _("Successfully uninstalled cogs: ") + humanize_list(uninstalled_cogs) - if failed_cogs: - message += ( - _( - "\nDownloader has removed these cogs from the installed cogs list" - " but it wasn't able to find their files: " + if len(uninstalled_cogs) > 1: + message += _("Successfully uninstalled cogs: ") + humanize_list( + uninstalled_cogs + ) + else: + message += _("Successfully uninstalled cog ") + uninstalled_cogs[0] + if failed_cogs: + if len(failed_cogs) > 1: + message += ( + _( + "\nDownloader has removed these cogs from the installed cogs list" + " but it wasn't able to find their files: " + ) + + humanize_list(tuple(map(inline, failed_cogs))) + + _( + "\nThey were most likely removed without using `{prefix}cog uninstall`.\n" + "You may need to remove those files manually if the cogs are still usable." + " If so, ensure the cogs have been unloaded with `{prefix}unload {cogs}`." + ).format(prefix=ctx.clean_prefix, cogs=" ".join(failed_cogs)) + ) + else: + message += _( + "\nDownloader has removed the cog {cog} from the installed cogs list" + " but it wasn't able to find his files." + ).format(cog=inline(failed_cogs[0])) + _( + "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" + "You may need to remove those files manually if the cog are still usable." + " If so, ensure the cog have been unloaded with `{prefix}unload {cog}`." + ).format( + prefix=ctx.clean_prefix, cog=failed_cogs[0] ) - + humanize_list(tuple(map(inline, failed_cogs))) - + _( - "\nThey were most likely removed without using `{prefix}cog uninstall`.\n" - "You may need to remove those files manually if the cogs are still usable." - " If so, ensure the cogs have been unloaded with `{prefix}unload {cogs}`." - ).format(prefix=ctx.clean_prefix, cogs=" ".join(failed_cogs)) - ) await self.send_pagified(ctx, message) @cog.command(name="pin", usage="") @@ -833,9 +856,15 @@ class Downloader(commands.Cog): if pinned: await self._save_to_installed(pinned) cognames = [inline(cog.name) for cog in pinned] - message += _("Pinned cogs: ") + humanize_list(cognames) + if len(pinned) > 1: + message += _("Pinned cogs: ") + humanize_list(cognames) + else: + message += _("Pinned {cog}").format(cognames[0]) if already_pinned: - message += _("\nThese cogs were already pinned: ") + humanize_list(already_pinned) + if len(already_pinned) > 1: + message += _("\nThese cogs were already pinned: ") + humanize_list(already_pinned) + else: + message += _("\n{cog} was already pinned.").format(cog=already_pinned[0]) await self.send_pagified(ctx, message) @cog.command(name="unpin", usage="") @@ -856,9 +885,15 @@ class Downloader(commands.Cog): if unpinned: await self._save_to_installed(unpinned) cognames = [inline(cog.name) for cog in unpinned] - message += _("Unpinned cogs: ") + humanize_list(cognames) + if len(unpinned) > 1: + message += _("Unpinned cogs: ") + humanize_list(cognames) + else: + message += _("Unpinned {cog}").format(cognames[0]) if not_pinned: - message += _("\nThese cogs weren't pinned: ") + humanize_list(not_pinned) + if len(unpinned) > 1: + message += _("\nThese cogs weren't pinned: ") + humanize_list(not_pinned) + else: + message += _("\n{cog} was already not pinned.").format(cog=not_pinned[0]) await self.send_pagified(ctx, message) @cog.command(name="listpinned") @@ -903,14 +938,22 @@ class Downloader(commands.Cog): message = "" if cogs_to_update: cognames = [cog.name for cog in cogs_to_update] - message += _("These cogs can be updated: ") + humanize_list( - tuple(map(inline, cognames)) - ) + if len(cogs_to_update) > 1: + message += _("These cogs can be updated: ") + humanize_list( + tuple(map(inline, cognames)) + ) + else: + message += _("{cog} can be updated.").format(cog=inline(cognames[0])) if libs_to_update: libnames = [cog.name for cog in libs_to_update] - message += _("\nThese shared libraries can be updated: ") + humanize_list( - tuple(map(inline, libnames)) - ) + if len(libnames) > 1: + message += _("\nThese shared libraries can be updated: ") + humanize_list( + tuple(map(inline, libnames)) + ) + else: + message += _("\nShared library {library} can be updated.").format( + library=inline(libnames[0]) + ) if not (cogs_to_update or libs_to_update) and filter_message: message += _("No cogs can be updated.") message += filter_message @@ -1068,23 +1111,49 @@ class Downloader(commands.Cog): @cog.command(name="list", usage="") async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None: """List all available cogs from a single repo.""" + available_cogs = 0 installed = await self.installed_cogs() - installed_str = "" - if installed: - installed_str = _("Installed Cogs:\n") + "\n".join( - [ - "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") - for i in installed - if i.repo_name == repo.name - ] + installed_str = "\n".join( + [ + "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") + for i in installed + if i.repo_name == repo.name + ] + ) + if not installed_str: + installed_str = _("No cogs installed.") + elif len(installed) > 1: + installed_str = ( + _("Installed Cogs: ({installed_number})\n").format(installed_number=len(installed)) + + installed_str ) - cogs = _("Available Cogs:\n") + "\n".join( + else: + installed_str = ( + _("Installed Cog: ({installed_number})\n").format(installed_number=len(installed)) + + installed_str + ) + available_str = "\n".join( [ "+ {}: {}".format(cog.name, cog.short or "") for cog in repo.available_cogs if not (cog.hidden or cog in installed) ] ) + for cog in repo.available_cogs: + if not (cog.hidden or cog in installed): + available_cogs += 1 + if not available_str: + cogs = _("No cogs available.") + elif available_cogs > 1: + cogs = ( + _("Available Cogs: ({available_number})\n").format(available_number=available_cogs) + + available_str + ) + else: + cogs = ( + _("Available Cog: ({available_number})\n").format(available_number=available_cogs) + + available_str + ) cogs = cogs + "\n\n" + installed_str for page in pagify(cogs, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) @@ -1172,17 +1241,30 @@ class Downloader(commands.Cog): message = "" if unavailable_cogs: - message += _("\nCouldn't find these cogs in {repo.name}: ").format( - repo=repo - ) + humanize_list(unavailable_cogs) + if len(unavailable_cogs) > 1: + message += _("\nCouldn't find these cogs in {repo.name}: ").format( + repo=repo + ) + humanize_list(unavailable_cogs) + else: + message += _("\nCouldn't find {cog} cog in {repo.name}").format( + cog=unavailable_cogs[0], repo=repo + ) if already_installed: - message += _("\nThese cogs were already installed: ") + humanize_list( - already_installed - ) + if len(already_installed) > 1: + message += _("\nThese cogs were already installed: ") + humanize_list( + already_installed + ) + else: + message += _("\n{cog} was already installed.").format(cog=already_installed[0]) if name_already_used: - message += _( - "\nSome cogs with these names are already installed from different repos: " - ) + humanize_list(name_already_used) + if len(name_already_used) > 1: + message += _( + "\nSome cogs with these names are already installed from different repos: " + ) + humanize_list(name_already_used) + else: + message += _( + "Cog with name {cog} is already installed from a different repo." + ).format(cog=name_already_used[0]) correct_cogs, add_to_message = self._filter_incorrect_cogs(cogs) if add_to_message: return correct_cogs, f"{message}{add_to_message}" @@ -1223,14 +1305,25 @@ class Downloader(commands.Cog): correct_cogs.append(cog) message = "" if outdated_python_version: - message += _( - "\nThese cogs require higher python version than you have: " - ) + humanize_list(outdated_python_version) + if len(outdated_python_version) > 1: + message += _( + "\nThese cogs require higher python version than you have: " + ) + humanize_list(outdated_python_version) + else: + message += _("{cog} require higher python version than you have.").format( + outdated_python_version[0] + ) if outdated_bot_version: - message += _( - "\nThese cogs require different Red version" - " than you currently have ({current_version}): " - ).format(current_version=red_version_info) + humanize_list(outdated_bot_version) + if len(outdated_bot_version) > 1: + message += _( + "\nThese cogs require different Red version" + " than you currently have ({current_version}): " + ).format(current_version=red_version_info) + humanize_list(outdated_bot_version) + else: + message += _( + "{cog} require different Red version than you currently " + "have ({current_version})" + ).format(cog=outdated_bot_version, current_version=red_version_info) return tuple(correct_cogs), message @@ -1293,22 +1386,45 @@ class Downloader(commands.Cog): updated_cognames: Set[str] = set() if installed_cogs: updated_cognames = {cog.name for cog in installed_cogs} - message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames))) + if len(installed_cogs) > 1: + message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames))) + else: + message += _("\n{cog} updated.").format( + cog=humanize_list(tuple(map(inline, updated_cognames))) + ) if failed_cogs: cognames = [cog.name for cog in failed_cogs] - message += _("\nFailed to update cogs: ") + humanize_list(tuple(map(inline, cognames))) + if len(failed_cogs) > 1: + message += _("\nFailed to update cogs: ") + humanize_list( + tuple(map(inline, cognames)) + ) + else: + message += _("\nFailed to update cog: ") + humanize_list( + tuple(map(inline, cognames)) + ) if not cogs_to_update: message = _("No cogs were updated.") if installed_libs: - message += _( - "\nSome shared libraries were updated, you should restart the bot " - "to bring the changes into effect." - ) + if len(installed_libs) > 1: + message += _( + "\nSome shared libraries were updated, you should restart the bot " + "to bring the changes into effect." + ) + else: + message += _( + "\nA shared library was updated, you should restart the " + "bot to bring the changes into effect." + ) if failed_libs: libnames = [lib.name for lib in failed_libs] - message += _("\nFailed to install shared libraries: ") + humanize_list( - tuple(map(inline, libnames)) - ) + if len(failed_cogs) > 1: + message += _("\nFailed to install shared libraries: ") + humanize_list( + tuple(map(inline, libnames)) + ) + else: + message += _("\nFailed to install shared library: ") + humanize_list( + tuple(map(inline, libnames)) + ) return (updated_cognames, message) async def _ask_for_cog_reload(self, ctx: commands.Context, updated_cognames: Set[str]) -> None: @@ -1318,7 +1434,12 @@ class Downloader(commands.Cog): return if not ctx.assume_yes: - message = _("Would you like to reload the updated cogs?") + if len(updated_cognames) > 1: + message = _("Would you like to reload the updated cogs?") + else: + message = _("Would you like to reload {cog}?").format( + cog=humanize_list(tuple(map(inline, updated_cognames))) + ) can_react = ctx.channel.permissions_for(ctx.me).add_reactions if not can_react: message += " (y/n)" From 4d8aff29d72af627770e0ef6e56477db31e8ed6a Mon Sep 17 00:00:00 2001 From: Predeactor <61093863+Predeactor@users.noreply.github.com> Date: Sun, 5 Jul 2020 14:09:25 +0200 Subject: [PATCH 02/28] Don't forget pipinstall --- redbot/cogs/downloader/downloader.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 0561f4d0a..40eed8e6f 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -474,14 +474,25 @@ class Downloader(commands.Cog): success = await repo.install_raw_requirements(deps, self.LIB_PATH) if success: - await ctx.send(_("Libraries installed.")) + if deps > 1: + await ctx.send(_("Libraries installed.")) + else: + await ctx.send(_("Library installed.")) else: - await ctx.send( - _( - "Some libraries failed to install. Please check" - " your logs for a complete list." + if deps > 1: + await ctx.send( + _( + "Some libraries failed to install. Please check" + " your logs for a complete list." + ) + ) + else: + await ctx.send( + _( + "The library failed to install. Please check " + "your logs for a complete list." + ) ) - ) @commands.group() @checks.is_owner() From 2a2bc2104f8093ee35aeaa27315e1188e53a0a5e Mon Sep 17 00:00:00 2001 From: Predeactor Date: Mon, 17 Aug 2020 23:40:01 +0000 Subject: [PATCH 03/28] Fix syntax issue --- redbot/cogs/downloader/downloader.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 2544a6265..18ce4a078 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1449,16 +1449,13 @@ class Downloader(commands.Cog): + _("\nYou can use {command} to see the updated statements.\n").format( command=inline(f"{ctx.clean_prefix}cog info ") ) - else: - message += ( - _("End user data statements for {cog} have been changed.").format( - cog=cogs_with_changed_eud_statement[0] - ) - + _("\nYou can use {command} to see the updated statements.\n").format( - command=inline(f"{ctx.clean_prefix}cog info ") - ) ) - ) + else: + message += _("End user data statements for {cog} have been changed.").format( + cog=cogs_with_changed_eud_statement[0] + ) + _("\nYou can use {command} to see the updated statements.\n").format( + command=inline(f"{ctx.clean_prefix}cog info ") + ) if failed_cogs: cognames = [cog.name for cog in failed_cogs] if len(failed_cogs) > 1: From 959c41aced2c25ef5c2738376e4d1febdc35029a Mon Sep 17 00:00:00 2001 From: Predeactor Date: Tue, 25 Aug 2020 19:15:30 +0000 Subject: [PATCH 04/28] This f****** fix that took me too much of my time for nothing. --- redbot/cogs/downloader/downloader.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 18ce4a078..45943c345 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1440,7 +1440,7 @@ class Downloader(commands.Cog): if len(installed_cogs) > 1: message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames))) else: - message += _("\n{cog} updated.").format(cog=updated_cognames[0]) + message += _("\n{cog} updated.").format(cog=inline(tuple(updated_cognames)[0])) if cogs_with_changed_eud_statement: if len(cogs_with_changed_eud_statement) > 1: message += ( @@ -1452,10 +1452,10 @@ class Downloader(commands.Cog): ) else: message += _("End user data statements for {cog} have been changed.").format( - cog=cogs_with_changed_eud_statement[0] - ) + _("\nYou can use {command} to see the updated statements.\n").format( - command=inline(f"{ctx.clean_prefix}cog info ") - ) + cog=tuple(cogs_with_changed_eud_statement)[0] + ) + _("\nYou can use {command} to see the updated statements.\n").format( + command=inline(f"{ctx.clean_prefix}cog info ") + ) if failed_cogs: cognames = [cog.name for cog in failed_cogs] if len(failed_cogs) > 1: From d5c22a4a8f9232cc65e708f620f9d989b9820b5e Mon Sep 17 00:00:00 2001 From: Predeactor Date: Tue, 25 Aug 2020 19:22:05 +0000 Subject: [PATCH 05/28] Black --- redbot/cogs/downloader/downloader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 45943c345..e393a3124 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1453,9 +1453,9 @@ class Downloader(commands.Cog): else: message += _("End user data statements for {cog} have been changed.").format( cog=tuple(cogs_with_changed_eud_statement)[0] - ) + _("\nYou can use {command} to see the updated statements.\n").format( - command=inline(f"{ctx.clean_prefix}cog info ") - ) + ) + _("\nYou can use {command} to see the updated statements.\n").format( + command=inline(f"{ctx.clean_prefix}cog info ") + ) if failed_cogs: cognames = [cog.name for cog in failed_cogs] if len(failed_cogs) > 1: From 04f903a4928c92b269fbf1f4da1a9c08418d09bd Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:15:39 +0200 Subject: [PATCH 06/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 302455db0..39755f56d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1588,7 +1588,7 @@ class Downloader(commands.Cog): else: message += _("End user data statements for {cog} have been changed.").format( cog=tuple(cogs_with_changed_eud_statement)[0] - ) + _("\nYou can use {command} to see the updated statements.\n").format( + ) + _("\nYou can use {command} to see the updated statement.\n").format( command=inline(f"{ctx.clean_prefix}cog info ") ) if failed_cogs: From 59b616deca8a6e79202ebb7ffad0331df22f43f3 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:17:19 +0200 Subject: [PATCH 07/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 39755f56d..aed695dcf 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -614,7 +614,7 @@ class Downloader(commands.Cog): repos = self._repo_manager.repos sorted_repos = sorted(repos, key=lambda r: str.lower(r.name)) if len(repos) == 0: - joined = _("There is no repo installed.") + joined = _("There are no repos installed.") else: if len(repos) > 1: joined = _("Installed Repos:\n\n") From c01d6ffbcba35db3e9b5c550671c014f0a47886d Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:17:38 +0200 Subject: [PATCH 08/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index aed695dcf..8ea460348 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -934,8 +934,10 @@ class Downloader(commands.Cog): + _( "\nThey were most likely removed without using `{prefix}cog uninstall`.\n" "You may need to remove those files manually if the cogs are still usable." - " If so, ensure the cogs have been unloaded with `{prefix}unload {cogs}`." - ).format(prefix=ctx.clean_prefix, cogs=" ".join(failed_cogs)) + " If so, ensure the cogs have been unloaded with {command}." + ).format( + command=inline(f"{ctx.clean_prefix}unload {' '.join(failed_cogs)}") + ) ) else: message += _( From 18aa2e035420087781996678148a1c63d7964ce9 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:17:45 +0200 Subject: [PATCH 09/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 8ea460348..6bc3be037 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -946,9 +946,8 @@ class Downloader(commands.Cog): ).format(cog=inline(failed_cogs[0])) + _( "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" "You may need to remove those files manually if the cog are still usable." - " If so, ensure the cog have been unloaded with `{prefix}unload {cog}`." - ).format( - prefix=ctx.clean_prefix, cog=failed_cogs[0] + " If so, ensure the cog has been unloaded with {command}." + ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}")) ) await self.send_pagified(ctx, message) From 8aa5c8d46deda443005bc0026b928f8d5d6b6540 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:17:54 +0200 Subject: [PATCH 10/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 6bc3be037..cde7732fc 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1486,7 +1486,7 @@ class Downloader(commands.Cog): "\nThese cogs require higher python version than you have: " ) + humanize_list(outdated_python_version) else: - message += _("{cog} require higher python version than you have.").format( + message += _("{cog} requires higher python version than you have.").format( outdated_python_version[0] ) if outdated_bot_version: From 0f6810ff9874e4fcd7f3aef43afbcc9c5fef741d Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:18:04 +0200 Subject: [PATCH 11/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index cde7732fc..0074f5f41 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1587,7 +1587,7 @@ class Downloader(commands.Cog): ) ) else: - message += _("End user data statements for {cog} have been changed.").format( + message += _("End user data statement for {cog} has been changed.").format( cog=tuple(cogs_with_changed_eud_statement)[0] ) + _("\nYou can use {command} to see the updated statement.\n").format( command=inline(f"{ctx.clean_prefix}cog info ") From e189f5361e6123225c60115d8e28fd8a03cf6d3e Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:18:22 +0200 Subject: [PATCH 12/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 0074f5f41..586ff1e3d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -945,7 +945,7 @@ class Downloader(commands.Cog): " but it wasn't able to find his files." ).format(cog=inline(failed_cogs[0])) + _( "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" - "You may need to remove those files manually if the cog are still usable." + "You may need to remove those files manually if the cog is still usable." " If so, ensure the cog has been unloaded with {command}." ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}")) ) From 7f8ed7bcf7f53f812c39a0cd354e9c82ef2feab1 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:18:44 +0200 Subject: [PATCH 13/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 586ff1e3d..ead44a706 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -922,7 +922,7 @@ class Downloader(commands.Cog): uninstalled_cogs ) else: - message += _("Successfully uninstalled cog ") + uninstalled_cogs[0] + message += _("Successfully uninstalled the cog: ") + uninstalled_cogs[0] if failed_cogs: if len(failed_cogs) > 1: message += ( From 1e0472ea9fe33eff687a23cc330a93c09f44e86e Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Mon, 29 Mar 2021 04:18:54 +0200 Subject: [PATCH 14/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index ead44a706..be3854e57 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1497,7 +1497,7 @@ class Downloader(commands.Cog): ).format(current_version=red_version_info) + humanize_list(outdated_bot_version) else: message += _( - "{cog} require different Red version than you currently " + "{cog} requires different Red version than you currently " "have ({current_version})" ).format(cog=outdated_bot_version, current_version=red_version_info) From e1228db7fcb0fd6de56f59a1da51e048f16a9af1 Mon Sep 17 00:00:00 2001 From: Predeactor Date: Mon, 29 Mar 2021 14:10:06 +0200 Subject: [PATCH 15/28] Fix Jack's syntax, remove numbers & fix bad calculated cogs --- redbot/cogs/downloader/downloader.py | 49 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index be3854e57..d064c1394 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -947,7 +947,7 @@ class Downloader(commands.Cog): "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" "You may need to remove those files manually if the cog is still usable." " If so, ensure the cog has been unloaded with {command}." - ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}")) + ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}") ) await self.send_pagified(ctx, message) @@ -1269,48 +1269,47 @@ class Downloader(commands.Cog): - `` The repo to list cogs from. """ - available_cogs = 0 - installed = await self.installed_cogs() + all_installed_cogs = await self.installed_cogs() + installed_cogs_in_repo = [ + cog + for cog in all_installed_cogs + if cog.repo_name == repo.name + ] installed_str = "\n".join( - [ - "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") - for i in installed - if i.repo_name == repo.name - ] + "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") + for i in installed_cogs_in_repo ) + if not installed_str: installed_str = _("No cogs installed.") - elif len(installed) > 1: + elif len(installed_cogs_in_repo) > 1: installed_str = ( - _("Installed Cogs: ({installed_number})\n").format(installed_number=len(installed)) - + installed_str + _("Installed Cogs:\n{text}").format(text=installed_str) ) else: installed_str = ( - _("Installed Cog: ({installed_number})\n").format(installed_number=len(installed)) - + installed_str + _("Installed Cog:\n{text}").format(text=installed_str) ) available_str = "\n".join( - [ - "+ {}: {}".format(cog.name, cog.short or "") - for cog in repo.available_cogs - if not (cog.hidden or cog in installed) - ] + "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") + for cog in repo.available_cogs + if not (cog.hidden or cog in installed_cogs_in_repo) ) - for cog in repo.available_cogs: - if not (cog.hidden or cog in installed): - available_cogs += 1 + + + available_cogs = sum( + not cog.hidden and cog not in installed_cogs_in_repo for cog in repo.available_cogs + ) + if not available_str: cogs = _("No cogs available.") elif available_cogs > 1: cogs = ( - _("Available Cogs: ({available_number})\n").format(available_number=available_cogs) - + available_str + _("Available Cogs:\n{text}").format(text=available_str) ) else: cogs = ( - _("Available Cog: ({available_number})\n").format(available_number=available_cogs) - + available_str + _("Available Cog:\n{text}").format(text=available_str) ) cogs = cogs + "\n\n" + installed_str for page in pagify(cogs, ["\n"], shorten_by=16): From f599ad22ec3d673822f2e861c7ccb34e645022dc Mon Sep 17 00:00:00 2001 From: Predeactor Date: Mon, 29 Mar 2021 14:14:07 +0200 Subject: [PATCH 16/28] Black ofc --- redbot/cogs/downloader/downloader.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index d064c1394..1d5999d2d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -947,7 +947,8 @@ class Downloader(commands.Cog): "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" "You may need to remove those files manually if the cog is still usable." " If so, ensure the cog has been unloaded with {command}." - ).format(command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}") + ).format( + command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}") ) await self.send_pagified(ctx, message) @@ -1270,11 +1271,7 @@ class Downloader(commands.Cog): - `` The repo to list cogs from. """ all_installed_cogs = await self.installed_cogs() - installed_cogs_in_repo = [ - cog - for cog in all_installed_cogs - if cog.repo_name == repo.name - ] + installed_cogs_in_repo = [cog for cog in all_installed_cogs if cog.repo_name == repo.name] installed_str = "\n".join( "- {}{}".format(i.name, ": {}".format(i.short) if i.short else "") for i in installed_cogs_in_repo @@ -1283,20 +1280,15 @@ class Downloader(commands.Cog): if not installed_str: installed_str = _("No cogs installed.") elif len(installed_cogs_in_repo) > 1: - installed_str = ( - _("Installed Cogs:\n{text}").format(text=installed_str) - ) + installed_str = _("Installed Cogs:\n{text}").format(text=installed_str) else: - installed_str = ( - _("Installed Cog:\n{text}").format(text=installed_str) - ) + installed_str = _("Installed Cog:\n{text}").format(text=installed_str) available_str = "\n".join( "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") for cog in repo.available_cogs if not (cog.hidden or cog in installed_cogs_in_repo) ) - available_cogs = sum( not cog.hidden and cog not in installed_cogs_in_repo for cog in repo.available_cogs ) @@ -1304,13 +1296,9 @@ class Downloader(commands.Cog): if not available_str: cogs = _("No cogs available.") elif available_cogs > 1: - cogs = ( - _("Available Cogs:\n{text}").format(text=available_str) - ) + cogs = _("Available Cogs:\n{text}").format(text=available_str) else: - cogs = ( - _("Available Cog:\n{text}").format(text=available_str) - ) + cogs = _("Available Cog:\n{text}").format(text=available_str) cogs = cogs + "\n\n" + installed_str for page in pagify(cogs, ["\n"], shorten_by=16): await ctx.send(box(page.lstrip(" "), lang="diff")) From 1fb028bc90335dce4cac14bbcbe11a729bf0e5ae Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:02:26 +0200 Subject: [PATCH 17/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 1d5999d2d..80c415db2 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1294,7 +1294,7 @@ class Downloader(commands.Cog): ) if not available_str: - cogs = _("No cogs available.") + cogs = _("Available Cogs:\nNo cogs are available.") elif available_cogs > 1: cogs = _("Available Cogs:\n{text}").format(text=available_str) else: From 42988f8e689d68da285153d82700bc6d51f796dc Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:02:33 +0200 Subject: [PATCH 18/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 80c415db2..41039fa60 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -499,7 +499,7 @@ class Downloader(commands.Cog): success = await repo.install_raw_requirements(deps, self.LIB_PATH) if success: - if deps > 1: + if len(deps) > 1: await ctx.send(_("Libraries installed.")) else: await ctx.send(_("Library installed.")) From 52d5f38137da8dd1b63da5eb6fcaa898ba58b98a Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:02:39 +0200 Subject: [PATCH 19/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 41039fa60..3c128f6da 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -504,7 +504,7 @@ class Downloader(commands.Cog): else: await ctx.send(_("Library installed.")) else: - if deps > 1: + if len(deps) > 1: await ctx.send( _( "Some libraries failed to install. Please check" From 4a735b902707280e98a64d40fc6805560bf3555e Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:02:47 +0200 Subject: [PATCH 20/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 3c128f6da..a6f872583 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -932,11 +932,12 @@ class Downloader(commands.Cog): ) + humanize_list(tuple(map(inline, failed_cogs))) + _( - "\nThey were most likely removed without using `{prefix}cog uninstall`.\n" + "\nThey were most likely removed without using {command_1}.\n" "You may need to remove those files manually if the cogs are still usable." - " If so, ensure the cogs have been unloaded with {command}." + " If so, ensure the cogs have been unloaded with {command_2}." ).format( - command=inline(f"{ctx.clean_prefix}unload {' '.join(failed_cogs)}") + command_1=inline(f"{ctx.clean_prefix}cog uninstall"), + command_2=inline(f"{ctx.clean_prefix}unload {' '.join(failed_cogs)}"), ) ) else: From e19f06929a0673789e6eb40c9e156e562f5c555b Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:02:55 +0200 Subject: [PATCH 21/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index a6f872583..94d96c246 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -945,11 +945,12 @@ class Downloader(commands.Cog): "\nDownloader has removed the cog {cog} from the installed cogs list" " but it wasn't able to find his files." ).format(cog=inline(failed_cogs[0])) + _( - "\nIt was most likely removed without using `{prefix}cog uninstall`.\n" + "\nIt was most likely removed without using {command_1}.\n" "You may need to remove those files manually if the cog is still usable." - " If so, ensure the cog has been unloaded with {command}." + " If so, ensure the cog has been unloaded with {command_2}." ).format( - command=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}") + command_1=inline(f"{ctx.clean_prefix}cog uninstall"), + command_2=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}"), ) await self.send_pagified(ctx, message) From 60a9c8a98ba63ad009e3010751c431649d047b38 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:03:06 +0200 Subject: [PATCH 22/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 94d96c246..88bec6667 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1017,7 +1017,7 @@ class Downloader(commands.Cog): else: message += _("Unpinned {cog}").format(cognames[0]) if not_pinned: - if len(unpinned) > 1: + if len(not_pinned) > 1: message += _("\nThese cogs weren't pinned: ") + humanize_list(not_pinned) else: message += _("\n{cog} was already not pinned.").format(cog=not_pinned[0]) From d0fd0e72b0d1d354e59950d64fcb45d414d2f31d Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:03:12 +0200 Subject: [PATCH 23/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 88bec6667..474d8de19 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1065,7 +1065,7 @@ class Downloader(commands.Cog): message = "" if cogs_to_update: cognames = [cog.name for cog in cogs_to_update] - if len(cogs_to_update) > 1: + if len(cognames) > 1: message += _("These cogs can be updated: ") + humanize_list( tuple(map(inline, cognames)) ) From ac7f22a87ea4c392c3c9d8578966f2371b86785c Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:03:20 +0200 Subject: [PATCH 24/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 474d8de19..3ecca0e44 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1576,7 +1576,7 @@ class Downloader(commands.Cog): ) ) else: - message += _("End user data statement for {cog} has been changed.").format( + message += _("End user data statement for {cog} has changed.").format( cog=tuple(cogs_with_changed_eud_statement)[0] ) + _("\nYou can use {command} to see the updated statement.\n").format( command=inline(f"{ctx.clean_prefix}cog info ") From 4bf878f5b095568981de8501dc17f2b9e1a0dc39 Mon Sep 17 00:00:00 2001 From: Pred <61093863+Predeactor@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:03:26 +0200 Subject: [PATCH 25/28] Update redbot/cogs/downloader/downloader.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/downloader/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 3ecca0e44..6e8f95233 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1627,7 +1627,7 @@ class Downloader(commands.Cog): message = _("Would you like to reload the updated cogs?") else: message = _("Would you like to reload {cog}?").format( - cog=humanize_list(tuple(map(inline, updated_cognames))) + cog=inline(updated_cognames[0]) ) can_react = ctx.channel.permissions_for(ctx.me).add_reactions if not can_react: From 9cc658580abd85febcf77ba9cb23fe5026388aa1 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 5 Apr 2021 16:33:28 +0200 Subject: [PATCH 26/28] Address my review comment --- redbot/cogs/downloader/downloader.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 6e8f95233..36b8f220a 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1279,11 +1279,9 @@ class Downloader(commands.Cog): for i in installed_cogs_in_repo ) - if not installed_str: - installed_str = _("No cogs installed.") - elif len(installed_cogs_in_repo) > 1: + if len(installed_cogs_in_repo) > 1: installed_str = _("Installed Cogs:\n{text}").format(text=installed_str) - else: + elif installed_cogs_in_repo: installed_str = _("Installed Cog:\n{text}").format(text=installed_str) available_str = "\n".join( "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") From 83f2627ee9455d9850631ce921a71e2acedb4fe4 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 5 Apr 2021 16:48:48 +0200 Subject: [PATCH 27/28] Simplify --- redbot/cogs/downloader/downloader.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 36b8f220a..4db37c27d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -1283,19 +1283,18 @@ class Downloader(commands.Cog): installed_str = _("Installed Cogs:\n{text}").format(text=installed_str) elif installed_cogs_in_repo: installed_str = _("Installed Cog:\n{text}").format(text=installed_str) + + available_cogs = [ + cog for cog in repo.available_cogs if not (cog.hidden or cog in installed_cogs_in_repo) + ] available_str = "\n".join( "+ {}{}".format(cog.name, ": {}".format(cog.short) if cog.short else "") - for cog in repo.available_cogs - if not (cog.hidden or cog in installed_cogs_in_repo) - ) - - available_cogs = sum( - not cog.hidden and cog not in installed_cogs_in_repo for cog in repo.available_cogs + for cog in available_cogs ) if not available_str: cogs = _("Available Cogs:\nNo cogs are available.") - elif available_cogs > 1: + elif len(available_cogs) > 1: cogs = _("Available Cogs:\n{text}").format(text=available_str) else: cogs = _("Available Cog:\n{text}").format(text=available_str) From f2981635e37e667fbbe02c3a2637533dc503b6b4 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Mon, 5 Apr 2021 18:24:11 +0200 Subject: [PATCH 28/28] this is kinda a lot but shh --- redbot/cogs/downloader/downloader.py | 310 ++++++++++++++------------- 1 file changed, 157 insertions(+), 153 deletions(-) diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 4db37c27d..dfe93686d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -499,25 +499,18 @@ class Downloader(commands.Cog): success = await repo.install_raw_requirements(deps, self.LIB_PATH) if success: - if len(deps) > 1: - await ctx.send(_("Libraries installed.")) - else: - await ctx.send(_("Library installed.")) + await ctx.send(_("Libraries installed.") if len(deps) > 1 else _("Library installed.")) else: - if len(deps) > 1: - await ctx.send( - _( - "Some libraries failed to install. Please check" - " your logs for a complete list." - ) + await ctx.send( + _( + "Some libraries failed to install. Please check" + " your logs for a complete list." ) - else: - await ctx.send( - _( - "The library failed to install. Please check " - "your logs for a complete list." - ) + if len(deps) > 1 + else _( + "The library failed to install. Please check your logs for a complete list." ) + ) @commands.group() @checks.is_owner() @@ -726,14 +719,18 @@ class Downloader(commands.Cog): all_failed_libs += failed_libs message = "" if failed_reqs: - message += _("Failed to install requirements: ") + humanize_list( - tuple(map(inline, failed_reqs)) - ) + message += ( + _("Failed to install requirements: ") + if len(failed_reqs) > 1 + else _("Failed to install the requirement: ") + ) + humanize_list(tuple(map(inline, failed_reqs))) if all_failed_libs: libnames = [lib.name for lib in failed_libs] - message += _("\nFailed to install shared libraries: ") + humanize_list( - tuple(map(inline, libnames)) - ) + message += ( + _("\nFailed to install shared libraries: ") + if len(all_failed_libs) > 1 + else _("\nFailed to install shared library: ") + ) + humanize_list(tuple(map(inline, libnames))) if message: await self.send_pagified( ctx, @@ -825,9 +822,11 @@ class Downloader(commands.Cog): return failed_reqs = await self._install_requirements(cogs) if failed_reqs: - message += _("\nFailed to install requirements: ") + humanize_list( - tuple(map(inline, failed_reqs)) - ) + message += ( + _("\nFailed to install requirements: ") + if len(failed_reqs) > 1 + else _("\nFailed to install requirement: ") + ) + humanize_list(tuple(map(inline, failed_reqs))) await self.send_pagified(ctx, message) return @@ -846,19 +845,33 @@ class Downloader(commands.Cog): if failed_libs: libnames = [inline(lib.name) for lib in failed_libs] message = ( - _("\nFailed to install shared libraries for `{repo.name}` repo: ").format( - repo=repo - ) + ( + _("\nFailed to install shared libraries for `{repo.name}` repo: ") + if len(libnames) > 1 + else _("\nFailed to install shared library for `{repo.name}` repo: ") + ).format(repo=repo) + humanize_list(libnames) + message ) if failed_cogs: cognames = [inline(cog.name) for cog in failed_cogs] - message = _("\nFailed to install cogs: ") + humanize_list(cognames) + message + message = ( + ( + _("\nFailed to install cogs: ") + if len(failed_cogs) > 1 + else _("\nFailed to install the cog: ") + ) + + humanize_list(cognames) + + message + ) if installed_cogs: cognames = [inline(cog.name) for cog in installed_cogs] message = ( - _("Successfully installed cogs: ") + ( + _("Successfully installed cogs: ") + if len(installed_cogs) > 1 + else _("Successfully installed the cog:") + ) + humanize_list(cognames) + ( _( @@ -917,12 +930,11 @@ class Downloader(commands.Cog): message = "" if uninstalled_cogs: - if len(uninstalled_cogs) > 1: - message += _("Successfully uninstalled cogs: ") + humanize_list( - uninstalled_cogs - ) - else: - message += _("Successfully uninstalled the cog: ") + uninstalled_cogs[0] + message += ( + _("Successfully uninstalled cogs: ") + if len(uninstalled_cogs) > 1 + else _("Successfully uninstalled the cog: ") + ) + humanize_list(uninstalled_cogs) if failed_cogs: if len(failed_cogs) > 1: message += ( @@ -941,16 +953,20 @@ class Downloader(commands.Cog): ) ) else: - message += _( - "\nDownloader has removed the cog {cog} from the installed cogs list" - " but it wasn't able to find his files." - ).format(cog=inline(failed_cogs[0])) + _( - "\nIt was most likely removed without using {command_1}.\n" - "You may need to remove those files manually if the cog is still usable." - " If so, ensure the cog has been unloaded with {command_2}." - ).format( - command_1=inline(f"{ctx.clean_prefix}cog uninstall"), - command_2=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}"), + message += ( + _( + "\nDownloader has removed this cog from the installed cogs list" + " but it wasn't able to find its files: " + ) + + inline(failed_cogs[0]) + + _( + "\nIt was most likely removed without using {command_1}.\n" + "You may need to remove those files manually if the cog is still usable." + " If so, ensure the cog has been unloaded with {command_2}." + ).format( + command_1=inline(f"{ctx.clean_prefix}cog uninstall"), + command_2=inline(f"{ctx.clean_prefix}unload {failed_cogs[0]}"), + ) ) await self.send_pagified(ctx, message) @@ -978,15 +994,15 @@ class Downloader(commands.Cog): if pinned: await self._save_to_installed(pinned) cognames = [inline(cog.name) for cog in pinned] - if len(pinned) > 1: - message += _("Pinned cogs: ") + humanize_list(cognames) - else: - message += _("Pinned {cog}").format(cognames[0]) + message += ( + _("Pinned cogs: ") if len(pinned) > 1 else _("Pinned cog: ") + ) + humanize_list(cognames) if already_pinned: - if len(already_pinned) > 1: - message += _("\nThese cogs were already pinned: ") + humanize_list(already_pinned) - else: - message += _("\n{cog} was already pinned.").format(cog=already_pinned[0]) + message += ( + _("\nThese cogs were already pinned: ") + if len(already_pinned) > 1 + else _("\nThis cog was already pinned: ") + ) + humanize_list(already_pinned) await self.send_pagified(ctx, message) @cog.command(name="unpin", require_var_positional=True) @@ -1012,15 +1028,15 @@ class Downloader(commands.Cog): if unpinned: await self._save_to_installed(unpinned) cognames = [inline(cog.name) for cog in unpinned] - if len(unpinned) > 1: - message += _("Unpinned cogs: ") + humanize_list(cognames) - else: - message += _("Unpinned {cog}").format(cognames[0]) + message += ( + _("Unpinned cogs: ") if len(unpinned) > 1 else _("Unpinned cog: ") + ) + humanize_list(cognames) if not_pinned: - if len(not_pinned) > 1: - message += _("\nThese cogs weren't pinned: ") + humanize_list(not_pinned) - else: - message += _("\n{cog} was already not pinned.").format(cog=not_pinned[0]) + message += ( + _("\nThese cogs weren't pinned: ") + if len(not_pinned) > 1 + else _("\nThis cog was already not pinned: ") + ) + humanize_list(not_pinned) await self.send_pagified(ctx, message) @cog.command(name="listpinned") @@ -1065,22 +1081,18 @@ class Downloader(commands.Cog): message = "" if cogs_to_update: cognames = [cog.name for cog in cogs_to_update] - if len(cognames) > 1: - message += _("These cogs can be updated: ") + humanize_list( - tuple(map(inline, cognames)) - ) - else: - message += _("{cog} can be updated.").format(cog=inline(cognames[0])) + message += ( + _("These cogs can be updated: ") + if len(cognames) > 1 + else _("This cog can be updated: ") + ) + humanize_list(tuple(map(inline, cognames))) if libs_to_update: libnames = [cog.name for cog in libs_to_update] - if len(libnames) > 1: - message += _("\nThese shared libraries can be updated: ") + humanize_list( - tuple(map(inline, libnames)) - ) - else: - message += _("\nShared library {library} can be updated.").format( - library=inline(libnames[0]) - ) + message += ( + _("\nThese shared libraries can be updated: ") + if len(libnames) > 1 + else _("\nThis shared library can be updated: ") + ) + humanize_list(tuple(map(inline, libnames))) if not (cogs_to_update or libs_to_update) and filter_message: message += _("No cogs can be updated.") message += filter_message @@ -1206,8 +1218,10 @@ class Downloader(commands.Cog): message += _("There were no cogs to check.") if pinned_cogs: cognames = [cog.name for cog in pinned_cogs] - message += _( - "\nThese cogs are pinned and therefore weren't checked: " + message += ( + _("\nThese cogs are pinned and therefore weren't checked: ") + if len(cognames) > 1 + else _("\nThis cog is pinned and therefore wasn't checked: ") ) + humanize_list(tuple(map(inline, cognames))) else: cogs_to_update, libs_to_update = await self._available_updates(cogs_to_check) @@ -1240,8 +1254,10 @@ class Downloader(commands.Cog): await repo.checkout(repo.branch) if pinned_cogs: cognames = [cog.name for cog in pinned_cogs] - message += _( - "\nThese cogs are pinned and therefore weren't checked: " + message += ( + _("\nThese cogs are pinned and therefore weren't checked: ") + if len(cognames) > 1 + else _("\nThis cog is pinned and therefore wasn't checked: ") ) + humanize_list(tuple(map(inline, cognames))) message += filter_message @@ -1403,30 +1419,23 @@ class Downloader(commands.Cog): message = "" if unavailable_cogs: - if len(unavailable_cogs) > 1: - message += _("\nCouldn't find these cogs in {repo.name}: ").format( - repo=repo - ) + humanize_list(unavailable_cogs) - else: - message += _("\nCouldn't find {cog} cog in {repo.name}").format( - cog=unavailable_cogs[0], repo=repo - ) + message = ( + _("\nCouldn't find these cogs in {repo.name}: ") + if len(unavailable_cogs) > 1 + else _("\nCouldn't find this cog in {repo.name}: ") + ) + humanize_list(unavailable_cogs) if already_installed: - if len(already_installed) > 1: - message += _("\nThese cogs were already installed: ") + humanize_list( - already_installed - ) - else: - message += _("\n{cog} was already installed.").format(cog=already_installed[0]) + message += ( + _("\nThese cogs were already installed: ") + if len(already_installed) > 1 + else _("\nThis cog was already installed: ") + ) + humanize_list(already_installed) if name_already_used: - if len(name_already_used) > 1: - message += _( - "\nSome cogs with these names are already installed from different repos: " - ) + humanize_list(name_already_used) - else: - message += _( - "Cog with name {cog} is already installed from a different repo." - ).format(cog=name_already_used[0]) + message += ( + _("\nSome cogs with these names are already installed from different repos: ") + if len(name_already_used) > 1 + else _("Cog with this is already installed from a different repo.") + ) + humanize_list(name_already_used) correct_cogs, add_to_message = self._filter_incorrect_cogs(cogs) if add_to_message: return correct_cogs, f"{message}{add_to_message}" @@ -1467,25 +1476,23 @@ class Downloader(commands.Cog): correct_cogs.append(cog) message = "" if outdated_python_version: - if len(outdated_python_version) > 1: - message += _( - "\nThese cogs require higher python version than you have: " - ) + humanize_list(outdated_python_version) - else: - message += _("{cog} requires higher python version than you have.").format( - outdated_python_version[0] - ) + message += ( + _("\nThese cogs require higher python version than you have: ") + if len(outdated_python_version) + else _("This cog requires higher python version than you have: ") + ) + humanize_list(outdated_python_version) if outdated_bot_version: - if len(outdated_bot_version) > 1: - message += _( + message += ( + _( "\nThese cogs require different Red version" " than you currently have ({current_version}): " - ).format(current_version=red_version_info) + humanize_list(outdated_bot_version) - else: - message += _( - "{cog} requires different Red version than you currently " - "have ({current_version})" - ).format(cog=outdated_bot_version, current_version=red_version_info) + ) + if len(outdated_bot_version) > 1 + else _( + "This cog requires different Red version than you currently " + "have ({current_version}): " + ) + ).format(current_version=red_version_info) + humanize_list(outdated_bot_version) return tuple(correct_cogs), message @@ -1542,7 +1549,11 @@ class Downloader(commands.Cog): if failed_reqs: return ( set(), - _("Failed to install requirements: ") + ( + _("Failed to install requirements: ") + if len(failed_reqs) > 1 + else _("Failed to install the requirement: ") + ) + humanize_list(tuple(map(inline, failed_reqs))), ) installed_cogs, failed_cogs = await self._install_cogs(cogs_to_update) @@ -1559,10 +1570,7 @@ class Downloader(commands.Cog): current_eud_statement = current_cog_versions_map[cog.name].end_user_data_statement if current_eud_statement != cog.end_user_data_statement: cogs_with_changed_eud_statement.add(cog.name) - if len(installed_cogs) > 1: - message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames))) - else: - message += _("\n{cog} updated.").format(cog=inline(tuple(updated_cognames)[0])) + message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames))) if cogs_with_changed_eud_statement: if len(cogs_with_changed_eud_statement) > 1: message += ( @@ -1573,44 +1581,41 @@ class Downloader(commands.Cog): ) ) else: - message += _("End user data statement for {cog} has changed.").format( - cog=tuple(cogs_with_changed_eud_statement)[0] - ) + _("\nYou can use {command} to see the updated statement.\n").format( - command=inline(f"{ctx.clean_prefix}cog info ") + message += ( + _("End user data statement of this cog has changed:") + + inline(next(iter(cogs_with_changed_eud_statement))) + + _("\nYou can use {command} to see the updated statement.\n").format( + command=inline(f"{ctx.clean_prefix}cog info ") + ) ) if failed_cogs: cognames = [cog.name for cog in failed_cogs] - if len(failed_cogs) > 1: - message += _("\nFailed to update cogs: ") + humanize_list( - tuple(map(inline, cognames)) - ) - else: - message += _("\nFailed to update cog: ") + humanize_list( - tuple(map(inline, cognames)) - ) + message += ( + _("\nFailed to update cogs: ") + if len(failed_cogs) > 1 + else _("\nFailed to update cog: ") + ) + humanize_list(tuple(map(inline, cognames))) if not cogs_to_update: message = _("No cogs were updated.") if installed_libs: - if len(installed_libs) > 1: - message += _( + message += ( + _( "\nSome shared libraries were updated, you should restart the bot " "to bring the changes into effect." ) - else: - message += _( + if len(installed_libs) > 1 + else _( "\nA shared library was updated, you should restart the " "bot to bring the changes into effect." ) + ) if failed_libs: libnames = [lib.name for lib in failed_libs] - if len(failed_cogs) > 1: - message += _("\nFailed to install shared libraries: ") + humanize_list( - tuple(map(inline, libnames)) - ) - else: - message += _("\nFailed to install shared library: ") + humanize_list( - tuple(map(inline, libnames)) - ) + message += ( + _("\nFailed to install shared libraries: ") + if len(failed_cogs) > 1 + else _("\nFailed to install shared library: ") + ) + humanize_list(tuple(map(inline, libnames))) return (updated_cognames, message) async def _ask_for_cog_reload(self, ctx: commands.Context, updated_cognames: Set[str]) -> None: @@ -1620,12 +1625,11 @@ class Downloader(commands.Cog): return if not ctx.assume_yes: - if len(updated_cognames) > 1: - message = _("Would you like to reload the updated cogs?") - else: - message = _("Would you like to reload {cog}?").format( - cog=inline(updated_cognames[0]) - ) + message = ( + _("Would you like to reload the updated cogs?") + if len(updated_cognames) > 1 + else _("Would you like to reload the updated cog?") + ) can_react = ctx.channel.permissions_for(ctx.me).add_reactions if not can_react: message += " (y/n)"