MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / summarize_book

Function summarize_book

web_programming/search_books_by_isbn.py:40–59  ·  view source on GitHub ↗

Given Open Library book data, return a summary as a Python dict.

(ol_book_data: dict)

Source from the content-addressed store, hash-verified

38
39
40def summarize_book(ol_book_data: dict) -> dict:
41 """
42 Given Open Library book data, return a summary as a Python dict.
43 """
44 desired_keys = {
45 "title": "Title",
46 "publish_date": "Publish date",
47 "authors": "Authors",
48 "number_of_pages": "Number of pages",
49 "isbn_10": "ISBN (10)",
50 "isbn_13": "ISBN (13)",
51 }
52 data = {better_key: ol_book_data[key] for key, better_key in desired_keys.items()}
53 data["Authors"] = [
54 get_openlibrary_data(author["key"])["name"] for author in data["Authors"]
55 ]
56 for key, value in data.items():
57 if isinstance(value, list):
58 data[key] = ", ".join(value)
59 return data
60
61
62if __name__ == "__main__":

Callers 1

Calls 1

get_openlibrary_dataFunction · 0.85

Tested by

no test coverage detected