Include 2019 in counts
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m20s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m20s
This commit is contained in:
parent
5a5752eae7
commit
0874ad78e0
1 changed files with 14 additions and 3 deletions
|
@ -127,7 +127,7 @@ class ElectionCog(commands.Cog):
|
|||
except ValueError:
|
||||
self.log.error("failed to parse %r", span)
|
||||
continue
|
||||
results[party] = [seats, change, 0]
|
||||
results[party] = [seats, change, 0, 0]
|
||||
# if not span:
|
||||
# self.log.warning("%r did not have a 'span' element.", child_ul)
|
||||
# continue
|
||||
|
@ -148,6 +148,17 @@ class ElectionCog(commands.Cog):
|
|||
# int(groups["net"].strip()) * MULTI[groups["net_change"]],
|
||||
# int(find_colour(child_ul.next["class"][0])[1:], base=16)
|
||||
# ]
|
||||
for child_li in good_soups[1].children:
|
||||
span = list(child_li.children)[-1]
|
||||
try:
|
||||
party, extra = span.get_text().strip().split(":", 1)
|
||||
seats, _ = extra.split(" ", 1)
|
||||
seats = int(seats)
|
||||
except ValueError:
|
||||
self.log.error("failed to parse %r", span)
|
||||
continue
|
||||
if party in results:
|
||||
results[party][3] = seats
|
||||
return results
|
||||
|
||||
async def _get_embed(self) -> discord.Embed | None:
|
||||
|
@ -170,11 +181,11 @@ class ElectionCog(commands.Cog):
|
|||
description_parts = []
|
||||
|
||||
for party_name, values in results.items():
|
||||
councillors, net, colour = values
|
||||
councillors, net, colour, last_election = values
|
||||
colour_scores[party_name] = councillors
|
||||
symbol = "+" if net > 0 else ''
|
||||
description_parts.append(
|
||||
f"**{party_name}**: {symbol}{net:,} ({councillors:,} total)"
|
||||
f"**{party_name}**: {symbol}{net:,} ({councillors:,} total, {last_election:,} in 2019)"
|
||||
)
|
||||
|
||||
top_party = list(sorted(colour_scores.keys(), key=lambda k: colour_scores[k], reverse=True))[0]
|
||||
|
|
Loading…
Reference in a new issue