Reduce copy pasted code for getting the ship dimensions
All checks were successful
Build and push / changes (push) Successful in 5s
Build and push / Lint-Python (push) Successful in 8s
Build and push / Build-and-Push-Docker (push) Successful in 1m17s
Build and push / sync-argocd-app (push) Successful in 2s

This commit is contained in:
Luke Robles 2024-11-10 21:14:35 -08:00
parent 81b71e4bce
commit 9d4e682cf9

View File

@ -413,42 +413,19 @@ async def get_ship(ship_name):
embed.add_field(name="**Expedite Fee**", value=expedite_fee, inline=True)
embed.add_field(name="-------", value="", inline=False)
dimensions = ["Length", "Width", "Height"]
for dimension in dimensions:
try:
length = (
value = (
soup.find(
"div", {"class": "template-dimensions-label"}, string="Length"
"div", {"class": "template-dimensions-label"}, string=dimension
)
.findNext("div", {"class": "template-dimensions-data"})
.text
)
except Exception:
length = "N/A"
embed.add_field(name="**Length**", value=length, inline=True)
try:
width = (
soup.find("div", {"class": "template-dimensions-label"}, string="Width")
.findNext("div", {"class": "template-dimensions-data"})
.text
)
except Exception:
width = "N/A"
embed.add_field(name="**Width**", value=width, inline=True)
try:
height = (
soup.find(
"div", {"class": "template-dimensions-label"}, string="Height"
)
.findNext("div", {"class": "template-dimensions-data"})
.text
)
except Exception:
height = "N/A"
embed.add_field(name="**Height**", value=height, inline=True)
value = "N/A"
embed.add_field(name=f"**{dimension}**", value=value, inline=True)
embed.add_field(
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False