MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / GET

Method GET

openlibrary/plugins/openlibrary/code.py:295–308  ·  view source on GitHub ↗
(self, key: str)

Source from the content-addressed store, hash-verified

293 path = r"(/works/OL\d+W|/books/OL\d+M)/widget"
294
295 def GET(self, key: str): # type: ignore[override]
296 olid = key.rsplit("/", maxsplit=1)[-1]
297 item = web.ctx.site.get(key)
298 is_work = key.startswith("/works/")
299 item["olid"] = olid
300 item["availability"] = get_availability(
301 "openlibrary_work" if is_work else "openlibrary_edition",
302 [olid],
303 ).get(olid)
304 item["authors"] = [web.storage(key=a.key, name=a.name or None) for a in item.get_authors()]
305 return delegate.RawText(
306 render_template("widget", format_work_data(item) if is_work else item),
307 content_type="text/html",
308 )
309
310
311def format_work_data(work):

Callers

nothing calls this directly

Calls 4

format_work_dataFunction · 0.85
render_templateFunction · 0.50
getMethod · 0.45
get_authorsMethod · 0.45

Tested by

no test coverage detected