|
471 | 471 | " trees = L(cells).map(NbCell.parsed_).concat()\n", |
472 | 472 | " r1 = [o for o in trees if isinstance(o, _assign_types)]\n", |
473 | 473 | " res = [nested_attr(o, 'value.value') for o in r1 if getattr(o.targets[0],'id',None)=='_doc_']\n", |
474 | | - " raise Exception(([getattr(o.targets[0],'id',None) for o in r1], trees, r1, res))\n", |
475 | 474 | " return f'\"\"\"{res[0]}\"\"\"\\n\\n' if res else \"\"" |
476 | 475 | ] |
477 | 476 | }, |
| 477 | + { |
| 478 | + "cell_type": "code", |
| 479 | + "execution_count": null, |
| 480 | + "metadata": {}, |
| 481 | + "outputs": [ |
| 482 | + { |
| 483 | + "ename": "Exception", |
| 484 | + "evalue": "(['a', '_doc_'], [<ast.Assign object at 0x118af96a0>, <ast.Assign object at 0x118afe610>], [<ast.Assign object at 0x118af96a0>, <ast.Assign object at 0x118afe610>], ['hi'])", |
| 485 | + "output_type": "error", |
| 486 | + "traceback": [ |
| 487 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 488 | + "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", |
| 489 | + "Input \u001b[0;32mIn [26]\u001b[0m, in \u001b[0;36m<cell line: 5>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m r1 \u001b[38;5;241m=\u001b[39m [o \u001b[38;5;28;01mfor\u001b[39;00m o \u001b[38;5;129;01min\u001b[39;00m trees \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(o, _assign_types)]\n\u001b[1;32m 4\u001b[0m res \u001b[38;5;241m=\u001b[39m [nested_attr(o, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvalue.value\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m o \u001b[38;5;129;01min\u001b[39;00m r1 \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mgetattr\u001b[39m(o\u001b[38;5;241m.\u001b[39mtargets[\u001b[38;5;241m0\u001b[39m],\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mid\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;28;01mNone\u001b[39;00m)\u001b[38;5;241m==\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_doc_\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(([\u001b[38;5;28mgetattr\u001b[39m(o\u001b[38;5;241m.\u001b[39mtargets[\u001b[38;5;241m0\u001b[39m],\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mid\u001b[39m\u001b[38;5;124m'\u001b[39m,\u001b[38;5;28;01mNone\u001b[39;00m) \u001b[38;5;28;01mfor\u001b[39;00m o \u001b[38;5;129;01min\u001b[39;00m r1], trees, r1, res))\n", |
| 490 | + "\u001b[0;31mException\u001b[0m: (['a', '_doc_'], [<ast.Assign object at 0x118af96a0>, <ast.Assign object at 0x118afe610>], [<ast.Assign object at 0x118af96a0>, <ast.Assign object at 0x118afe610>], ['hi'])" |
| 491 | + ] |
| 492 | + } |
| 493 | + ], |
| 494 | + "source": [ |
| 495 | + "cells = make_code_cells(\"a = 'b'\\n_doc_ = 'hi'\")\n", |
| 496 | + "trees = L(cells).map(NbCell.parsed_).concat()\n", |
| 497 | + "r1 = [o for o in trees if isinstance(o, _assign_types)]\n", |
| 498 | + "res = [nested_attr(o, 'value.value') for o in r1 if getattr(o.targets[0],'id',None)=='_doc_']\n", |
| 499 | + "raise Exception(([getattr(o.targets[0],'id',None) for o in r1], trees, r1, res))" |
| 500 | + ] |
| 501 | + }, |
478 | 502 | { |
479 | 503 | "cell_type": "code", |
480 | 504 | "execution_count": null, |
|
0 commit comments