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

Method verify_types

openlibrary/plugins/openlibrary/code.py:893–914  ·  view source on GitHub ↗
(self, query)

Source from the content-addressed store, hash-verified

891 return query["key"]
892
893 def verify_types(self, query):
894 if isinstance(query, list):
895 for q in query:
896 self.verify_types(q)
897 else:
898 if "type" not in query:
899 raise BadRequest("Missing type")
900 type = query["type"]
901 if isinstance(type, dict):
902 if "key" not in type:
903 raise BadRequest("Bad Type: " + json.dumps(type))
904 type = type["key"]
905
906 if type not in [
907 "/type/author",
908 "/type/edition",
909 "/type/work",
910 "/type/series",
911 "/type/publisher",
912 "/type/tag",
913 ]:
914 raise BadRequest("Bad Type: " + json.dumps(type))
915
916 def POST(self):
917 if not can_write():

Callers 1

POSTMethod · 0.95

Calls 2

BadRequestClass · 0.85
dumpsMethod · 0.80

Tested by

no test coverage detected