Skip to content

Commit

Permalink
Merge branch 'V3/develop' into V3/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCos17 authored Nov 6, 2024
2 parents 1beed32 + 30058c0 commit 496e58d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
12 changes: 8 additions & 4 deletions redbot/cogs/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,18 @@ async def _repo_list(self, ctx: commands.Context) -> None:
joined = _("There are no repos installed.")
else:
if len(repos) > 1:
joined = _("# Installed Repos\n")
joined = _("## Installed Repos\n")
else:
joined = _("# Installed Repo\n")
joined = _("## Installed Repo\n")
for repo in sorted_repos:
joined += "+ {}: {}\n".format(repo.name, repo.short or "")
joined += "- **{}:** {}\n - {}\n".format(
repo.name,
repo.short or "",
"<{}>".format(repo.url),
)

for page in pagify(joined, ["\n"], shorten_by=16):
await ctx.send(box(page.lstrip(" "), lang="markdown"))
await ctx.send(page)

@repo.command(name="info")
async def _repo_info(self, ctx: commands.Context, repo: Repo) -> None:
Expand Down
6 changes: 4 additions & 2 deletions redbot/cogs/trivia/data/lists/harrypotter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ What are draco's parents' names?:
- Narcissa and Lucious
What book does Hermione insist Ron and Harry read?:
- Hogwarts, A History
- Hogwarts A History
What breed was Hagrid's pet dragon?:
- Norwegian Ridgeback
What color are unicorn foals?:
Expand Down Expand Up @@ -194,7 +195,7 @@ What is Severus Snape's mother's first name?:
What is Tonks's first name?:
- Nymphadora
What is considered Harry's 'trademark spell'?:
- Expelliarmus.
- Expelliarmus
What is the Hogwarts School motto in English?:
- Never Tickle a Sleeping Dragon
What is the age requirement for an Apparation License?:
Expand Down Expand Up @@ -222,6 +223,7 @@ What is the name of Dumbledore's phoenix?:
- fawkes
What is the name of Filch's cat?:
- Mrs. Norris
- Mrs Norris
What is the name of Harry Potter’s pet owl?:
- Hedwig
What is the name of Harry's aunt?:
Expand Down Expand Up @@ -609,4 +611,4 @@ How many hours into the past do Harry and Hermione travel in an attempt to rescu
- Three
How many muggles did Peter Pettigrew kill when he faked his own death?:
- 12
- Twelve
- Twelve
17 changes: 10 additions & 7 deletions redbot/cogs/trivia/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

UNIQUE_ID = 0xB3C0E453
_ = Translator("Trivia", __file__)
YAMLSafeLoader = getattr(yaml, "CSafeLoader", yaml.SafeLoader)


class InvalidListError(Exception):
Expand Down Expand Up @@ -759,7 +760,7 @@ async def _save_trivia_list(
return

buffer = io.BytesIO(await attachment.read())
trivia_dict = yaml.safe_load(buffer)
trivia_dict = yaml.load(buffer, YAMLSafeLoader)
TRIVIA_LIST_SCHEMA.validate(trivia_dict)

buffer.seek(0)
Expand Down Expand Up @@ -803,7 +804,7 @@ def get_core_lists() -> List[pathlib.Path]:
return list(core_lists_path.glob("*.yaml"))


def get_list(path: pathlib.Path) -> Dict[str, Any]:
def get_list(path: pathlib.Path, *, validate_schema: bool = True) -> Dict[str, Any]:
"""
Returns a trivia list dictionary from the given path.
Expand All @@ -814,12 +815,14 @@ def get_list(path: pathlib.Path) -> Dict[str, Any]:
"""
with path.open(encoding="utf-8") as file:
try:
trivia_dict = yaml.safe_load(file)
trivia_dict = yaml.load(file, YAMLSafeLoader)
except yaml.error.YAMLError as exc:
raise InvalidListError("YAML parsing failed.") from exc

try:
TRIVIA_LIST_SCHEMA.validate(trivia_dict)
except schema.SchemaError as exc:
raise InvalidListError("The list does not adhere to the schema.") from exc
if validate_schema:
try:
TRIVIA_LIST_SCHEMA.validate(trivia_dict)
except schema.SchemaError as exc:
raise InvalidListError("The list does not adhere to the schema.") from exc

return trivia_dict

0 comments on commit 496e58d

Please sign in to comment.