Convert keys from /a/, /b/, /l/ and /user/ to /authors/, /books/, /languages/ and /people/ respectively.
(data)
| 293 | |
| 294 | |
| 295 | def _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 | |
| 313 | def _make_sub(d): |
no test coverage detected