mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-07 14:17:36 -05:00
refactor(build): accept Path directly in build() signature
Remove internal str->Path conversion; callers and tests now pass Path objects directly. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -133,11 +133,10 @@ def format_stars_short(stars: int) -> str:
|
||||
return str(stars)
|
||||
|
||||
|
||||
def build(repo_root: str) -> None:
|
||||
def build(repo_root: Path) -> None:
|
||||
"""Main build: parse README, render single-page HTML via Jinja2 templates."""
|
||||
repo = Path(repo_root)
|
||||
website = repo / "website"
|
||||
readme_text = (repo / "README.md").read_text(encoding="utf-8")
|
||||
website = repo_root / "website"
|
||||
readme_text = (repo_root / "README.md").read_text(encoding="utf-8")
|
||||
|
||||
subtitle = ""
|
||||
for line in readme_text.split("\n"):
|
||||
@@ -208,4 +207,4 @@ def build(repo_root: str) -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
build(str(Path(__file__).parent.parent))
|
||||
build(Path(__file__).parent.parent)
|
||||
|
||||
@@ -108,7 +108,7 @@ class TestBuild:
|
||||
Help!
|
||||
""")
|
||||
self._make_repo(tmp_path, readme)
|
||||
build(str(tmp_path))
|
||||
build(tmp_path)
|
||||
|
||||
site = tmp_path / "website" / "output"
|
||||
assert (site / "index.html").exists()
|
||||
@@ -135,7 +135,7 @@ class TestBuild:
|
||||
stale.mkdir(parents=True)
|
||||
(stale / "index.html").write_text("old", encoding="utf-8")
|
||||
|
||||
build(str(tmp_path))
|
||||
build(tmp_path)
|
||||
|
||||
assert not (tmp_path / "website" / "output" / "categories" / "stale").exists()
|
||||
|
||||
@@ -162,7 +162,7 @@ class TestBuild:
|
||||
Done.
|
||||
""")
|
||||
self._make_repo(tmp_path, readme)
|
||||
build(str(tmp_path))
|
||||
build(tmp_path)
|
||||
|
||||
index_html = (tmp_path / "website" / "output" / "index.html").read_text()
|
||||
assert "Alpha" in index_html
|
||||
@@ -186,7 +186,7 @@ class TestBuild:
|
||||
Done.
|
||||
""")
|
||||
self._make_repo(tmp_path, readme)
|
||||
build(str(tmp_path))
|
||||
build(tmp_path)
|
||||
|
||||
index_html = (tmp_path / "website" / "output" / "index.html").read_text()
|
||||
assert "django" in index_html
|
||||
@@ -224,7 +224,7 @@ class TestBuild:
|
||||
}
|
||||
(data_dir / "github_stars.json").write_text(json.dumps(stars), encoding="utf-8")
|
||||
|
||||
build(str(tmp_path))
|
||||
build(tmp_path)
|
||||
|
||||
html = (tmp_path / "website" / "output" / "index.html").read_text(encoding="utf-8")
|
||||
# Star-sorted: high-stars (5000) before low-stars (100) before no-stars (None)
|
||||
|
||||
Reference in New Issue
Block a user