Stronger presence check

- Fixes `out-of-range` on a Tuple
- Ensures `KeyError` doesn't happen for the faulty key. I would argue if someone the script should be re-written to accommodate this in the first place.
This commit is contained in:
Avineshwar Pratap Singh 2020-11-23 09:52:16 -06:00 • committed by GitHub
commit 4cde49ddca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -174,7 +174,7 @@ class Display:
("Title", info["title"]), ("Authors", ", ".join(aut["name"] for aut in info["authors"])), ("Title", info["title"]), ("Authors", ", ".join(aut["name"] for aut in info["authors"])),
("Identifier", info["identifier"]), ("ISBN", info["isbn"]), ("Identifier", info["identifier"]), ("ISBN", info["isbn"]),
("Publishers", ", ".join(pub["name"] for pub in info["publishers"])), ("Publishers", ", ".join(pub["name"] for pub in info["publishers"])),
("Rights", info["rights"]), ("Rights", info["rights"] if "rights" in info and info["rights"] else ""),
("Description", description[:500] + "..." if len(description) >= 500 else description), ("Description", description[:500] + "..." if len(description) >= 500 else description),
("Release Date", info["issued"]), ("Release Date", info["issued"]),
("URL", info["web_url"]) ("URL", info["web_url"])
@ -961,7 +961,7 @@ class SafariBooks:
escape(self.book_info["description"]), escape(self.book_info["description"]),
subjects, subjects,
", ".join(escape(pub["name"]) for pub in self.book_info["publishers"]), ", ".join(escape(pub["name"]) for pub in self.book_info["publishers"]),
escape(self.book_info["rights"]) if self.book_info["rights"] else "", escape(self.book_info["rights"]) if "rights" in self.book_info and self.book_info["rights"] else "",
self.book_info["issued"], self.book_info["issued"],
self.cover, self.cover,
"\n".join(manifest), "\n".join(manifest),