Just merge all the CSS into one
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 16s

This commit is contained in:
Nexus 2024-05-03 19:14:33 +01:00
parent 0ff3de0ea4
commit 16bd14bdc1
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -49,7 +49,7 @@ class ElectionCog(commands.Cog):
if not good_soup:
return
css: str = [x for x in good_soup.find_all("style") if "Results" in x.get_text()][0].get_text()
css: str = "\n".join([x.get_text() for x in good_soup.find_all("style") if "Results" in x.get_text()])
def find_colour(style_name: str, want: str = "background-colour") -> str | None:
index = css.index(style_name) + len(style_name) + 1
@ -58,13 +58,13 @@ class ElectionCog(commands.Cog):
if char == "}":
break
value += char
attributes = filter(value.split(";"))
attributes = filter(None, value.split(";"))
parsed = {}
for attr in attributes:
name, val = attr.split(":")
parsed[name] = val
if want in parsed:
return parsed[name]
return parsed[want]
results: dict[str, list[int]] = {}
for child_ul in good_soup.children:
@ -104,7 +104,7 @@ class ElectionCog(commands.Cog):
)
# noinspection PyTypeChecker
soup = await asyncio.to_thread(BeautifulSoup, response.text)
soup = await asyncio.to_thread(BeautifulSoup, response.text, "html.parser")
results = await self.bot.loop.run_in_executor(None, self.process_soup, soup)
if results:
date = ctx.message.created_at.date().strftime("%B %Y")