Fix errors by just returning N/A

This commit is contained in:
Luke Robles 2023-05-07 13:09:35 -07:00
parent 9643ba71b8
commit 2113203be1

View File

@ -90,37 +90,55 @@ async def get_ship(ship_name):
# embed.add_field(name="**Description**", value=ship["description"], inline=False) # embed.add_field(name="**Description**", value=ship["description"], inline=False)
embed.add_field(name="-------", value="", inline=False) embed.add_field(name="-------", value="", inline=False)
stowage_capacity = ( try:
soup.find("tr", {"class": "data-stowagespace infobox-data infobox-col2"}) stowage_capacity = (
.findChildren("td")[0] soup.find(
.text "tr", {"class": "data-stowagespace infobox-data infobox-col2"}
) )
.findChildren("td")[0]
.text
)
except Exception:
stowage_capacity = "N/A"
embed.add_field( embed.add_field(
name="**Stowage Capacity**", value=stowage_capacity, inline=True name="**Stowage Capacity**", value=stowage_capacity, inline=True
) )
cargo_capacity = ( try:
soup.find("tr", {"class": "data-cargocapacity infobox-data infobox-col4"}) cargo_capacity = (
.findChildren("td")[0] soup.find(
.text "tr", {"class": "data-cargocapacity infobox-data infobox-col4"}
) )
.findChildren("td")[0]
.text
)
except Exception:
cargo_capacity = "N/A"
embed.add_field(name="**Cargo Capacity**", value=cargo_capacity, inline=True) embed.add_field(name="**Cargo Capacity**", value=cargo_capacity, inline=True)
crew_size = ( try:
soup.find("tr", {"class": "data-crew infobox-data infobox-col4"}) crew_size = (
.findChildren("td")[0] soup.find("tr", {"class": "data-crew infobox-data infobox-col4"})
.text .findChildren("td")[0]
) .text
)
except Exception:
crew_size = "N/A"
embed.add_field(name="**Crew Size**", value=crew_size, inline=True) embed.add_field(name="**Crew Size**", value=crew_size, inline=True)
embed.add_field(name="-------", value="", inline=False) embed.add_field(name="-------", value="", inline=False)
claim_time = ( try:
soup.find("div", {"class": "data-claimtime infobox-data infobox-col4"}) claim_time = (
.find("div", {"class": "infobox-data__value"}) soup.find("div", {"class": "data-claimtime infobox-data infobox-col4"})
.text .find("div", {"class": "infobox-data__value"})
) .text
)
except Exception:
claim_time = "N/A"
embed.add_field(name="**Insurance claim time**", value=claim_time, inline=True) embed.add_field(name="**Insurance claim time**", value=claim_time, inline=True)
try: try:
@ -131,24 +149,24 @@ async def get_ship(ship_name):
.find("div", {"class": "infobox-data__value"}) .find("div", {"class": "infobox-data__value"})
.text .text
) )
embed.add_field( except Exception:
name="**Expedite claim time**", value=expedited_claim_time, inline=True expedited_claim_time = "N/A"
) embed.add_field(
except Exception as e: name="**Expedite claim time**", value=expedited_claim_time, inline=True
print(e) )
try: try:
expedited_fee = ( expedite_fee = (
soup.find( soup.find(
"div", {"class": "data-expeditecost infobox-data infobox-col2"} "div", {"class": "data-expeditecost infobox-data infobox-col2"}
) )
.find("div", {"class": "infobox-data__value"}) .find("div", {"class": "infobox-data__value"})
.text .text
) )
embed.add_field(name="**Expedite Fee**", value=expedited_fee, inline=True) except Exception:
except Exception as e: expedite_fee = "N/A"
print(e)
pass embed.add_field(name="**Expedite Fee**", value=expedite_fee, inline=True)
embed.add_field( embed.add_field(
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False
@ -164,7 +182,6 @@ async def get_ship(ship_name):
% ship_name, % ship_name,
inline=True, inline=True,
) )
print(e)
return embed return embed
return embed return embed