[V3 Downloader] Make hidden hidden and add disabled (#1828)

* Make hidden hidden and add disabled

* Add documentation
This commit is contained in:
Will 2018-06-08 20:39:07 -04:00 committed by GitHub
parent b983d5904b
commit b041d59fc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View File

@ -29,7 +29,9 @@ 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)``
- ``hidden`` (bool) - Determines if a cog is available for install.
- ``hidden`` (bool) - Determines if a cog is visible in the cog list for a repo.
- ``disabled`` (bool) - Determines if a cog is available for install.
- ``required_cogs`` (map of cogname to repo URL) - A map of required cogs that this cog depends on.
Downloader will not deal with this functionality but it may be useful for other cogs.

View File

@ -394,7 +394,11 @@ class Downloader:
)
cogs = repo_name.available_cogs
cogs = _("Available Cogs:\n") + "\n".join(
["+ {}: {}".format(c.name, c.short or "") for c in cogs if c not in installed]
[
"+ {}: {}".format(c.name, c.short or "")
for c in cogs
if not (c.hidden or c in installed)
]
)
cogs = cogs + "\n\n" + installed_str
for page in pagify(cogs, ["\n"], shorten_by=16):

View File

@ -75,6 +75,7 @@ class Installable(RepoJSONMixin):
self.bot_version = (3, 0, 0)
self.min_python_version = (3, 5, 1)
self.hidden = False
self.disabled = False
self.required_cogs = {} # Cog name -> repo URL
self.requirements = ()
self.tags = ()
@ -173,6 +174,12 @@ class Installable(RepoJSONMixin):
hidden = False
self.hidden = hidden
try:
disabled = bool(info.get("disabled", False))
except ValueError:
disabled = False
self.disabled = disabled
self.required_cogs = info.get("required_cogs", {})
self.requirements = info.get("requirements", ())

View File

@ -470,7 +470,7 @@ class Repo(RepoJSONMixin):
"""
# noinspection PyTypeChecker
return tuple(
[m for m in self.available_modules if m.type == InstallableType.COG and not m.hidden]
[m for m in self.available_modules if m.type == InstallableType.COG and not m.disabled]
)
@property