Skip to content

Commit

Permalink
[Downloader] Move author key handling to RepoJSONMixin, fix `Name…
Browse files Browse the repository at this point in the history
…Error` (#3285)

* Update downloader.py

* Update json_mixins.py

* Update installable.py

* changelog pt 1

* changelog pt2

* edit of changelog pt1

* edit of changelog pt 2 (last commit before review)

* Kidding, this is the last one before review.
  • Loading branch information
Jackenmen authored and Michael H committed Jan 8, 2020
1 parent f5949f2 commit af859aa
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.d/downloader/3285.misc.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `NameError` in :func:`redbot.cogs.downloader.downloader.Downloader._filter_incorrect_cogs_by_names()`.
1 change: 1 addition & 0 deletions changelog.d/downloader/3285.misc.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move handling of ``author`` key in ``info.json`` to :func:`redbot.cogs.downloader.json_mixins.RepoJSONMixin`.
2 changes: 1 addition & 1 deletion redbot/cogs/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ async def _filter_incorrect_cogs_by_names(
if name_already_used:
message += _(
"\nSome cogs with these names are already installed from different repos: "
) + humanize_list(already_installed)
) + 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}"
Expand Down
7 changes: 0 additions & 7 deletions redbot/cogs/downloader/installable.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __init__(self, location: Path, repo: Optional[Repo] = None, commit: str = ""
self.repo_name = self._location.parent.stem
self.commit = commit

self.author: Tuple[str, ...] = ()
self.min_bot_version = red_version_info
self.max_bot_version = red_version_info
self.min_python_version = (3, 5, 1)
Expand Down Expand Up @@ -171,12 +170,6 @@ def _process_info_file(
else:
self._info = info

try:
author = tuple(info.get("author", []))
except ValueError:
author = ()
self.author = author

try:
min_bot_version = VersionInfo.from_str(str(info.get("min_bot_version", __version__)))
except ValueError:
Expand Down
9 changes: 7 additions & 2 deletions redbot/cogs/downloader/json_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RepoJSONMixin:
def __init__(self, repo_folder: Path):
self._repo_folder = repo_folder

self.author: Optional[Tuple[str, ...]] = None
self.author: Tuple[str, ...] = ()
self.install_msg: Optional[str] = None
self.short: Optional[str] = None
self.description: Optional[str] = None
Expand All @@ -32,7 +32,12 @@ def _read_info_file(self) -> None:
else:
self._info = info

self.author = info.get("author")
try:
author = tuple(info.get("author", []))
except ValueError:
author = ()
self.author = author

self.install_msg = info.get("install_msg")
self.short = info.get("short")
self.description = info.get("description")

0 comments on commit af859aa

Please sign in to comment.