Skip to content

Commit

Permalink
fix output formatting of extra methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Oct 30, 2024
1 parent 0e10acf commit b7b5651
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/codeboxapi/codebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,18 @@ def _parse_size(self, size_str: str) -> int:
return -1

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

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

async def arestart(self) -> None:
"""Restart the Jupyter kernel"""
Expand Down

0 comments on commit b7b5651

Please sign in to comment.