Skip to content
Permalink
Browse files

Merge branch 'V3/develop' into V3/issue_2527

  • Loading branch information
jack1142 committed Apr 29, 2019
2 parents 6c43972 + 1ce3bc2 commit 842b951ce27bbcb23f6624b8b5cb9028bca55402
@@ -34,6 +34,8 @@ Core
----

* Delete cooldown messages when expired (`#2469`_)
* ``[p]set locale`` now only accepts actual locales (`#2553`_)
* ``[p]listlocales`` now displays en-US (`#2553`_)
* ``redbot --version`` will now give you current version of Red (`#2567`_)

------
@@ -54,9 +56,12 @@ Downloader
----------

* ``[p]cog install`` will now tell user that cog has to be loaded (`#2523`_)
* The message when libraries fail to install is now formatted (`#2576`_)
* Fixed bug, that caused Downloader to include submodules on cog list (`#2590`_)
* ``[p]cog uninstall`` allows to uninstall multiple cogs now (`#2592`_)
* ``[p]cog uninstall`` will now remove cog from installed cogs even if it can't find the cog in install path anymore (`#2595`_)
* ``[p]cog install`` will not allow to install cogs which aren't suitable for installed version of Red anymore (`#2605`_)
* Cog Developers now have to use ``min_bot_version`` in form of version string instead of ``bot_version`` in info.json and they can also use ``max_bot_version`` to specify maximum version of Red, more in :doc:`framework_downloader`. (`#2605`_)

---
Mod
@@ -123,10 +128,12 @@ Utility Functions
.. _#2540: https://github.com/Cog-Creators/Red-DiscordBot/pull/2540
.. _#2545: https://github.com/Cog-Creators/Red-DiscordBot/pull/2545
.. _#2550: https://github.com/Cog-Creators/Red-DiscordBot/pull/2550
.. _#2553: https://github.com/Cog-Creators/Red-DiscordBot/pull/2553
.. _#2556: https://github.com/Cog-Creators/Red-DiscordBot/pull/2556
.. _#2557: https://github.com/Cog-Creators/Red-DiscordBot/pull/2557
.. _#2565: https://github.com/Cog-Creators/Red-DiscordBot/pull/2565
.. _#2567: https://github.com/Cog-Creators/Red-DiscordBot/pull/2567
.. _#2576: https://github.com/Cog-Creators/Red-DiscordBot/pull/2576
.. _#2579: https://github.com/Cog-Creators/Red-DiscordBot/pull/2579
.. _#2586: https://github.com/Cog-Creators/Red-DiscordBot/pull/2586
.. _#2590: https://github.com/Cog-Creators/Red-DiscordBot/pull/2590
@@ -136,5 +143,6 @@ Utility Functions
.. _#2600: https://github.com/Cog-Creators/Red-DiscordBot/pull/2600
.. _#2602: https://github.com/Cog-Creators/Red-DiscordBot/pull/2602
.. _#2604: https://github.com/Cog-Creators/Red-DiscordBot/pull/2604
.. _#2605: https://github.com/Cog-Creators/Red-DiscordBot/pull/2605
.. _#2606: https://github.com/Cog-Creators/Red-DiscordBot/pull/2606
.. _#2620: https://github.com/Cog-Creators/Red-DiscordBot/pull/2620
@@ -30,7 +30,10 @@ Keys common to both repo and cog info.json (case sensitive)
Keys specific to the cog info.json (case sensitive)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- ``bot_version`` (list of integer) - Min version number of Red in the format ``(MAJOR, MINOR, PATCH)``
- ``min_bot_version`` (string) - Min version number of Red in the format ``MAJOR.MINOR.MICRO``

- ``max_bot_version`` (string) - Max version number of Red in the format ``MAJOR.MINOR.MICRO``,
if ``min_bot_version`` is newer than ``max_bot_version``, ``max_bot_version`` will be ignored

- ``hidden`` (bool) - Determines if a cog is visible in the cog list for a repo.

@@ -119,8 +119,14 @@ def to_json(self) -> _Dict[str, _Union[int, str]]:
"dev_release": self.dev_release,
}

def __lt__(self, other: "VersionInfo") -> bool:
tups: _List[_Tuple[int, int, int, int, int, int, int]] = []
def _generate_comparison_tuples(
self, other: "VersionInfo"
) -> _List[
_Tuple[int, int, int, int, _Union[int, float], _Union[int, float], _Union[int, float]]
]:
tups: _List[
_Tuple[int, int, int, int, _Union[int, float], _Union[int, float], _Union[int, float]]
] = []
for obj in (self, other):
tups.append(
(
@@ -133,8 +139,20 @@ def __lt__(self, other: "VersionInfo") -> bool:
obj.dev_release if obj.dev_release is not None else _inf,
)
)
return tups

def __lt__(self, other: "VersionInfo") -> bool:
tups = self._generate_comparison_tuples(other)
return tups[0] < tups[1]

def __eq__(self, other: "VersionInfo") -> bool:
tups = self._generate_comparison_tuples(other)
return tups[0] == tups[1]

def __le__(self, other: "VersionInfo") -> bool:
tups = self._generate_comparison_tuples(other)
return tups[0] <= tups[1]

def __str__(self) -> str:
ret = f"{self.major}.{self.minor}.{self.micro}"
if self.releaselevel != self.FINAL:
@@ -9,7 +9,7 @@
from collections import defaultdict

import discord
from redbot.core import checks, commands, Config
from redbot.core import checks, commands, Config, version_info as red_version_info
from redbot.core.bot import Red
from redbot.core.data_manager import cog_data_path
from redbot.core.i18n import Translator, cog_i18n
@@ -591,7 +591,8 @@ def __init__(self, bot: Red):

poss_installed_path = (await self.cog_install_path()) / real_name
if poss_installed_path.exists():
ctx.bot.unload_extension(real_name)
with contextlib.suppress(commands.ExtensionNotLoaded):
ctx.bot.unload_extension(real_name)
await self._delete_cog(poss_installed_path)
uninstalled_cogs.append(inline(real_name))
else:
@@ -851,7 +852,8 @@ def __init__(self, bot: Red):
cogs: List[Installable] = []
unavailable_cogs: List[str] = []
already_installed: List[str] = []
outdated_python_version: List[Tuple[str, str]] = []
outdated_python_version: List[str] = []
outdated_bot_version: List[str] = []

for cog_name in cog_names:
cog: Installable = discord.utils.get(repo.available_cogs, name=cog_name)
@@ -864,11 +866,28 @@ def __init__(self, bot: Red):
if cog.min_python_version > sys.version_info:
outdated_python_version.append(
inline(cog_name)
+ _(" (Minimum: {version})").format(
version=".".join([str(n) for n in cog.min_python_version])
+ _(" (Minimum: {min_version})").format(
min_version=".".join([str(n) for n in cog.min_python_version])
)
)
continue
ignore_max = cog.min_bot_version > cog.max_bot_version
if (
cog.min_bot_version > red_version_info
or not ignore_max
and cog.max_bot_version < red_version_info
):
outdated_bot_version.append(
inline(cog_name)
+ _(" (Minimum: {min_version}").format(min_version=cog.min_bot_version)
+ (
""
if ignore_max
else _(", at most: {max_version}").format(max_version=cog.max_bot_version)
)
+ ")"
)
continue
cogs.append(cog)

message = ""
@@ -885,6 +904,11 @@ def __init__(self, bot: Red):
message += _(
"\nThese cogs require higher python version than you have: "
) + humanize_list(outdated_python_version)
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)

return (tuple(cogs), message)

@@ -8,6 +8,8 @@
from .log import log
from .json_mixins import RepoJSONMixin

from redbot.core import __version__, version_info as red_version_info, VersionInfo

if TYPE_CHECKING:
from .repo_manager import RepoManager, Repo

@@ -81,7 +83,8 @@ def __init__(self, location: Path, repo: Optional["Repo"] = None, commit: str =
self.commit = commit

self.author = ()
self.bot_version = (3, 0, 0)
self.min_bot_version = red_version_info
self.max_bot_version = red_version_info
self.min_python_version = (3, 5, 1)
self.hidden = False
self.disabled = False
@@ -166,10 +169,16 @@ def _process_info_file(self, info_file_path: Path = None) -> MutableMapping[str,
self.author = author

try:
bot_version = tuple(info.get("bot_version", [3, 0, 0]))
min_bot_version = VersionInfo.from_str(str(info.get("min_bot_version", __version__)))
except ValueError:
min_bot_version = self.min_bot_version
self.min_bot_version = min_bot_version

try:
max_bot_version = VersionInfo.from_str(str(info.get("max_bot_version", __version__)))
except ValueError:
bot_version = self.bot_version
self.bot_version = bot_version
max_bot_version = self.max_bot_version
self.max_bot_version = max_bot_version

try:
min_python_version = tuple(info.get("min_python_version", [3, 5, 1]))
@@ -91,7 +91,8 @@ def bot_repo(event_loop):
# Installable
INFO_JSON = {
"author": ("tekulvw",),
"bot_version": (3, 0, 0),
"min_bot_version": "3.0.0",
"max_bot_version": "3.0.2",
"description": "A long description",
"hidden": False,
"install_msg": "A post-installation message",
@@ -104,7 +105,8 @@ def bot_repo(event_loop):

LIBRARY_INFO_JSON = {
"author": ("seputaes",),
"bot_version": (3, 0, 0),
"min_bot_version": "3.0.0",
"max_bot_version": "3.0.2",
"description": "A long library description",
"hidden": False, # libraries are always hidden, this tests it will be flipped
"install_msg": "A library install message",
@@ -5,12 +5,15 @@

from redbot.pytest.downloader import *
from redbot.cogs.downloader.installable import Installable, InstallableType
from redbot.core import VersionInfo


def test_process_info_file(installable):
for k, v in INFO_JSON.items():
if k == "type":
assert installable.type == InstallableType.COG
elif k in ("min_bot_version", "max_bot_version"):
assert getattr(installable, k) == VersionInfo.from_str(v)
else:
assert getattr(installable, k) == v

@@ -19,6 +22,8 @@ def test_process_lib_info_file(library_installable):
for k, v in LIBRARY_INFO_JSON.items():
if k == "type":
assert library_installable.type == InstallableType.SHARED_LIBRARY
elif k in ("min_bot_version", "max_bot_version"):
assert getattr(library_installable, k) == VersionInfo.from_str(v)
elif k == "hidden":
# libraries are always hidden, even if False
assert library_installable.hidden is True

0 comments on commit 842b951

Please sign in to comment.
You can’t perform that action at this time.