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

Function _process_data

openlibrary/data/dump.py:295–310  ·  view source on GitHub ↗

Convert keys from /a/, /b/, /l/ and /user/ to /authors/, /books/, /languages/ and /people/ respectively.

(data)

Source from the content-addressed store, hash-verified

293
294
295def _process_data(data):
296 """Convert keys from /a/, /b/, /l/ and /user/
297 to /authors/, /books/, /languages/ and /people/ respectively."""
298 if isinstance(data, list):
299 return [_process_data(d) for d in data]
300 elif isinstance(data, dict):
301 if "key" in data:
302 data["key"] = _process_key(data["key"])
303
304 # convert date to ISO format
305 if data.get("type") == "/type/datetime":
306 data["value"] = data["value"].replace(" ", "T")
307
308 return {k: _process_data(v) for k, v in data.items()}
309 else:
310 return data
311
312
313def _make_sub(d):

Callers 1

print_dumpFunction · 0.70

Calls 3

_process_keyFunction · 0.70
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected