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

Function process_version

openlibrary/plugins/upstream/utils.py:537–554  ·  view source on GitHub ↗

Looks at the version and adds machine_comment required for showing "View MARC" link.

(v: HasGetKeyRevision)

Source from the content-addressed store, hash-verified

535
536@public
537def process_version(v: HasGetKeyRevision) -> HasGetKeyRevision:
538 """Looks at the version and adds machine_comment required for showing "View MARC" link."""
539 comments = [
540 "found a matching marc record",
541 "add publisher and source",
542 ]
543
544 if v.key.startswith("/books/") and not v.get("machine_comment"):
545 thing = v.get("thing") or web.ctx.site.get(v.key, v.revision)
546 if (thing.source_records and v.revision == 1) or (
547 v.comment and v.comment.lower() in comments # type: ignore [attr-defined]
548 ):
549 marc = thing.source_records[-1]
550 if marc.startswith("marc:"):
551 v.machine_comment = marc[len("marc:") :] # type: ignore [attr-defined]
552 else:
553 v.machine_comment = marc # type: ignore [attr-defined]
554 return v
555
556
557@public

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected