Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__/
*.py[cod]
*.egg-info/
.venv/


20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# toy01_table_stripper

This is a minimal Python package that demonstrates how to use the `uv` tool for
managing dependencies and running the application.

## Development

Create a virtual environment and install dependencies using `uv`:

```bash
uv venv
uv pip install -e .
```

Run the command-line interface by piping an HTML file:

```bash
cat sample.html | toy01-table-stripper
```

17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build-system]
requires = ["uv>=0.1.0"]
build-backend = "uv.build"

[project]
name = "toy01_table_stripper"
version = "0.1.0"
readme = "README.md"
authors = [
{name = "pathcosmos", email = "lanco.gh@gmail.com"}
]
dependencies = []
requires-python = ">=3.10"

[project.scripts]
toy01-table-stripper = "toy01_table_stripper.main:main"

20 changes: 20 additions & 0 deletions toy01_table_stripper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""toy01_table_stripper package."""

__all__ = ["strip_table"]


def strip_table(data: str) -> str:
"""Return the input string without any HTML <table> tags."""
result_lines = []
in_table = False
for line in data.splitlines():
if "<table" in line:
in_table = True
continue
if "</table>" in line:
in_table = False
continue
if not in_table:
result_lines.append(line)
return "\n".join(result_lines)

15 changes: 15 additions & 0 deletions toy01_table_stripper/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

import sys
from toy01_table_stripper import strip_table


def main() -> int:
data = sys.stdin.read()
print(strip_table(data))
return 0


if __name__ == "__main__":
raise SystemExit(main())