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

Function visit

openlibrary/plugins/openlibrary/code.py:197–220  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

195 visited = set()
196
197 def visit(key):
198 if key in visited or key.startswith("/type/"):
199 return
200 elif key in visiting:
201 # This is a case of circular-dependency. Add a stub object to break it.
202 print(json.dumps({"key": key, "type": visiting[key]["type"]}))
203 visited.add(key)
204 return
205
206 thing = web.ctx.site.get(key)
207 if not thing:
208 return
209
210 d = thing.dict()
211 d.pop("permission", None)
212 d.pop("child_permission", None)
213 d.pop("table_of_contents", None)
214
215 visiting[key] = d
216 for ref in get_references(d.values()):
217 visit(ref)
218 visited.add(key)
219
220 print(json.dumps(d))
221
222 keys = [
223 "/scan_record",

Callers 1

sampledumpFunction · 0.85

Calls 6

dumpsMethod · 0.80
get_referencesFunction · 0.70
addMethod · 0.45
getMethod · 0.45
dictMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected