Skip to content

Commit b7b5651

Browse files
committed
fix output formatting of extra methods
1 parent 0e10acf commit b7b5651

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/codeboxapi/codebox.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,18 @@ def _parse_size(self, size_str: str) -> int:
211211
return -1
212212

213213
async def alist_packages(self) -> list[str]:
214-
return (await self.aexec("uv pip list", kernel="bash")).text.splitlines()
214+
return (
215+
await self.aexec(
216+
"uv pip list | tail -n +3 | cut -d ' ' -f 1",
217+
kernel="bash",
218+
)
219+
).text.splitlines()
215220

216221
async def ashow_variables(self) -> dict[str, str]:
217-
vars = [line.strip() for line in (await self.aexec("%who")).text.strip()]
218-
return {v: (await self.aexec(v)).text for v in vars}
222+
vars = [
223+
line.strip() for line in (await self.aexec("%who")).text.strip().split()
224+
]
225+
return {v: (await self.aexec(f"print({v}, end='')")).text for v in vars}
219226

220227
async def arestart(self) -> None:
221228
"""Restart the Jupyter kernel"""

0 commit comments

Comments
 (0)