|
53 | 53 | "from IPython.display import display,Markdown\n", |
54 | 54 | "from monsterui.all import franken_class_map,apply_classes\n", |
55 | 55 | "from fasthtml.common import Safe,Script,Div\n", |
56 | | - "from toolslm.xml import repo2ctx,folder2ctx" |
| 56 | + "from toolslm.xml import *" |
57 | 57 | ] |
58 | 58 | }, |
59 | 59 | { |
|
551 | 551 | { |
552 | 552 | "data": { |
553 | 553 | "text/plain": [ |
554 | | - "'import json,importlib,linecache,re,inspect,uuid\\nfrom typing import Dict\\nfrom tempfile import TemporaryDirectory\\nfrom ipykernel_helper import *\\nfrom dataclasses import dataclass\\nfrom fastcore.xml import to_xml\\n\\nfrom fastcore.utils import *\\nfrom fastcore.meta import delegates\\nfrom ghapi.all import *\\nfrom fastlite import *\\nfrom fastcore.xtras import asdict\\nfrom inspect import currentframe,Parameter,signature\\nfrom httpx import get as xget, post as xpost\\nfrom IPython.display import display,Markdown\\nfrom monsterui.all import franken_class_map,apply_classes\\nfrom fasthtml.common import Safe,Script,Div\\nfrom toolslm.xml import repo2ctx'" |
| 554 | + "'import json,importlib,linecache,re,inspect,uuid\\nfrom typing import Dict\\nfrom tempfile import TemporaryDirectory\\nfrom ipykernel_helper import *\\nfrom dataclasses import dataclass\\nfrom fastcore.xml import to_xml\\n\\nfrom fastcore.utils import *\\nfrom fastcore.meta import delegates\\nfrom ghapi.all import *\\nfrom fastlite import *\\nfrom fastcore.xtras import asdict\\nfrom inspect import currentframe,Parameter,signature\\nfrom httpx import get as xget, post as xpost\\nfrom IPython.display import display,Markdown\\nfrom monsterui.all import franken_class_map,apply_classes\\nfrom fasthtml.common import Safe,Script,Div\\nfrom toolslm.xml import repo2ctx,folder2ctx'" |
555 | 555 | ] |
556 | 556 | }, |
557 | 557 | "execution_count": null, |
|
713 | 713 | "output_type": "stream", |
714 | 714 | "text": [ |
715 | 715 | "_9c544573\n", |
716 | | - "_2a6c39e8\n" |
| 716 | + "_87a4343f\n" |
717 | 717 | ] |
718 | 718 | } |
719 | 719 | ], |
|
989 | 989 | { |
990 | 990 | "data": { |
991 | 991 | "text/plain": [ |
992 | | - "'_675a14d7'" |
| 992 | + "'_996622fa'" |
993 | 993 | ] |
994 | 994 | }, |
995 | 995 | "execution_count": null, |
|
1314 | 1314 | "source": [ |
1315 | 1315 | "#| export\n", |
1316 | 1316 | "@delegates(folder2ctx)\n", |
1317 | | - "def get_folder(\n", |
| 1317 | + "def ctx_folder(\n", |
1318 | 1318 | " path:Path='.', # Path to collect\n", |
1319 | 1319 | " types:str|list='py,doc', # list or comma-separated str of ext types from: py, js, java, c, cpp, rb, r, ex, sh, web, doc, cfg\n", |
1320 | 1320 | " out=False, # Include notebook cell outputs?\n", |
1321 | 1321 | " **kwargs\n", |
1322 | 1322 | "):\n", |
1323 | 1323 | " \"Convert folder to XML context and place in a new message\"\n", |
1324 | 1324 | " res = folder2ctx(path, types=types, out=out, **kwargs)\n", |
1325 | | - " return add_msg(res, msg_type='raw');" |
| 1325 | + " return add_msg(res, msg_type='raw')" |
1326 | 1326 | ] |
1327 | 1327 | }, |
1328 | 1328 | { |
|
1366 | 1366 | "source": [ |
1367 | 1367 | "#| export\n", |
1368 | 1368 | "@delegates(repo2ctx)\n", |
1369 | | - "def get_repo(\n", |
| 1369 | + "def ctx_repo(\n", |
1370 | 1370 | " owner:str, # GitHub repo owner\n", |
1371 | 1371 | " repo:str, # GitHub repo name\n", |
1372 | 1372 | " types:str|list='py,doc', # list or comma-separated str of ext types from: py, js, java, c, cpp, rb, r, ex, sh, web, doc, cfg\n", |
|
1375 | 1375 | "):\n", |
1376 | 1376 | " \"Convert GitHub repo to XML context and place in a new message\"\n", |
1377 | 1377 | " res = repo2ctx(owner, repo, out=out, **kwargs)\n", |
1378 | | - " return add_msg(res, msg_type='raw');" |
| 1378 | + " return add_msg(res, msg_type='raw')" |
1379 | 1379 | ] |
1380 | 1380 | }, |
1381 | 1381 | { |
|
1419 | 1419 | "[TRUNCATED: output size 123364 exceeded max size 500 bytes]" |
1420 | 1420 | ] |
1421 | 1421 | }, |
| 1422 | + { |
| 1423 | + "cell_type": "code", |
| 1424 | + "execution_count": null, |
| 1425 | + "id": "5bd8915b", |
| 1426 | + "metadata": {}, |
| 1427 | + "outputs": [], |
| 1428 | + "source": [ |
| 1429 | + "#| export\n", |
| 1430 | + "@delegates(sym2file)\n", |
| 1431 | + "def ctx_symfile(sym):\n", |
| 1432 | + " \"Add note with filepath and contents for a symbol's source file\"\n", |
| 1433 | + " return add_msg(sym2file(sym), msg_type='note');" |
| 1434 | + ] |
| 1435 | + }, |
| 1436 | + { |
| 1437 | + "cell_type": "code", |
| 1438 | + "execution_count": null, |
| 1439 | + "id": "6180d2a3", |
| 1440 | + "metadata": {}, |
| 1441 | + "outputs": [ |
| 1442 | + { |
| 1443 | + "data": { |
| 1444 | + "text/plain": [ |
| 1445 | + "'_030ef334'" |
| 1446 | + ] |
| 1447 | + }, |
| 1448 | + "execution_count": null, |
| 1449 | + "metadata": {}, |
| 1450 | + "output_type": "execute_result" |
| 1451 | + } |
| 1452 | + ], |
| 1453 | + "source": [ |
| 1454 | + "# ctx_symfile(TemporaryDirectory)" |
| 1455 | + ] |
| 1456 | + }, |
| 1457 | + { |
| 1458 | + "cell_type": "code", |
| 1459 | + "execution_count": null, |
| 1460 | + "id": "bbc9bd0c", |
| 1461 | + "metadata": {}, |
| 1462 | + "outputs": [], |
| 1463 | + "source": [ |
| 1464 | + "#| export\n", |
| 1465 | + "@delegates(sym2folderctx)\n", |
| 1466 | + "def ctx_symfolder(\n", |
| 1467 | + " sym, # Symbol to get folder context from\n", |
| 1468 | + " **kwargs):\n", |
| 1469 | + " \"Add raw message with folder context for a symbol's source file location\"\n", |
| 1470 | + " return add_msg(sym2folderctx(sym, **kwargs), msg_type='raw');" |
| 1471 | + ] |
| 1472 | + }, |
| 1473 | + { |
| 1474 | + "cell_type": "code", |
| 1475 | + "execution_count": null, |
| 1476 | + "id": "7a308942", |
| 1477 | + "metadata": {}, |
| 1478 | + "outputs": [ |
| 1479 | + { |
| 1480 | + "data": { |
| 1481 | + "text/plain": [ |
| 1482 | + "'_b4d835be'" |
| 1483 | + ] |
| 1484 | + }, |
| 1485 | + "execution_count": null, |
| 1486 | + "metadata": {}, |
| 1487 | + "output_type": "execute_result" |
| 1488 | + } |
| 1489 | + ], |
| 1490 | + "source": [ |
| 1491 | + "# ctx_symfolder(folder2ctx)" |
| 1492 | + ] |
| 1493 | + }, |
| 1494 | + { |
| 1495 | + "cell_type": "code", |
| 1496 | + "execution_count": null, |
| 1497 | + "id": "9d8d83b5", |
| 1498 | + "metadata": {}, |
| 1499 | + "outputs": [], |
| 1500 | + "source": [ |
| 1501 | + "#| export\n", |
| 1502 | + "@delegates(sym2folderctx)\n", |
| 1503 | + "def ctx_sympkg(\n", |
| 1504 | + " sym, # Symbol to get folder context from\n", |
| 1505 | + " **kwargs):\n", |
| 1506 | + " \"Add raw message with repo context for a symbol's root package\"\n", |
| 1507 | + " return add_msg(sym2pkgctx(sym, **kwargs), msg_type='raw');" |
| 1508 | + ] |
| 1509 | + }, |
| 1510 | + { |
| 1511 | + "cell_type": "code", |
| 1512 | + "execution_count": null, |
| 1513 | + "id": "11c8b385", |
| 1514 | + "metadata": {}, |
| 1515 | + "outputs": [ |
| 1516 | + { |
| 1517 | + "data": { |
| 1518 | + "text/plain": [ |
| 1519 | + "'_c6181f90'" |
| 1520 | + ] |
| 1521 | + }, |
| 1522 | + "execution_count": null, |
| 1523 | + "metadata": {}, |
| 1524 | + "output_type": "execute_result" |
| 1525 | + } |
| 1526 | + ], |
| 1527 | + "source": [ |
| 1528 | + "# ctx_sympkg(folder2ctx)" |
| 1529 | + ] |
| 1530 | + }, |
1422 | 1531 | { |
1423 | 1532 | "cell_type": "markdown", |
1424 | 1533 | "id": "4cfd0bc5", |
|
1459 | 1568 | { |
1460 | 1569 | "data": { |
1461 | 1570 | "text/plain": [ |
1462 | | - "{'success': 'Inserted text after line 5 in message _0f6c9b92'}" |
| 1571 | + "{'success': 'Inserted text after line 5 in message _70e14974'}" |
1463 | 1572 | ] |
1464 | 1573 | }, |
1465 | 1574 | "execution_count": null, |
|
1528 | 1637 | { |
1529 | 1638 | "data": { |
1530 | 1639 | "text/plain": [ |
1531 | | - "{'success': 'Replaced text in message _0f6c9b92'}" |
| 1640 | + "{'success': 'Replaced text in message _70e14974'}" |
1532 | 1641 | ] |
1533 | 1642 | }, |
1534 | 1643 | "execution_count": null, |
|
1600 | 1709 | { |
1601 | 1710 | "data": { |
1602 | 1711 | "text/plain": [ |
1603 | | - "{'success': 'Successfully replaced all the strings in message _0f6c9b92'}" |
| 1712 | + "{'success': 'Successfully replaced all the strings in message _70e14974'}" |
1604 | 1713 | ] |
1605 | 1714 | }, |
1606 | 1715 | "execution_count": null, |
|
1689 | 1798 | { |
1690 | 1799 | "data": { |
1691 | 1800 | "text/plain": [ |
1692 | | - "{'success': 'Replaced lines 2 to 4 in message _0f6c9b92'}" |
| 1801 | + "{'success': 'Replaced lines 2 to 4 in message _70e14974'}" |
1693 | 1802 | ] |
1694 | 1803 | }, |
1695 | 1804 | "execution_count": null, |
|
1758 | 1867 | { |
1759 | 1868 | "data": { |
1760 | 1869 | "text/plain": [ |
1761 | | - "{'success': 'Deleted lines 2 to 4 in message _0f6c9b92'}" |
| 1870 | + "{'success': 'Deleted lines 2 to 4 in message _70e14974'}" |
1762 | 1871 | ] |
1763 | 1872 | }, |
1764 | 1873 | "execution_count": null, |
|
0 commit comments