Skip to content
Merged
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ a key, add `--voice Aman` to narrate with a macOS voice instead.
## Graduates

<!-- graduates:start -->
**3 graduates** finished the course with a pull request merged in a real open source project. [See the wall](graduates/) · [Join them](lessons/15-capstone/)
**2 graduates** finished the course with a pull request merged in a real open source project. The most recent is first. [See the wall](graduates/) · [Join them](lessons/15-capstone/)

<a href="https://github.com/divya0795"><img src="https://github.com/divya0795.png?size=96" width="48" height="48" alt="@divya0795" title="Divya"></a>
<a href="https://github.com/karthikaun"><img src="https://github.com/karthikaun.png?size=96" width="48" height="48" alt="@karthikaun" title="Karthik"></a>
<a href="https://github.com/thejesh23"><img src="https://github.com/thejesh23.png?size=96" width="48" height="48" alt="@thejesh23" title="Thejesh"></a>
<!-- graduates:end -->

Expand Down
4 changes: 1 addition & 3 deletions graduates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ merged in a real open source project. See

This page is generated by `tools/graduates_wall.py`. Don't edit it by hand.

**3 graduates**
**2 graduates**, the most recent first.

<a href="https://github.com/divya0795"><img src="https://github.com/divya0795.png?size=128" width="64" height="64" alt="@divya0795" title="Divya"></a>
<a href="https://github.com/karthikaun"><img src="https://github.com/karthikaun.png?size=128" width="64" height="64" alt="@karthikaun" title="Karthik"></a>
<a href="https://github.com/thejesh23"><img src="https://github.com/thejesh23.png?size=128" width="64" height="64" alt="@thejesh23" title="Thejesh"></a>

| Name | GitHub | Contribution | Message |
|---|---|---|---|
| Divya | [@divya0795](https://github.com/divya0795) | [psf/black#5711](https://github.com/psf/black/pull/5711) | Made Black reject --line-ranges for notebooks detected by their .ipynb extension. |
| Karthik | [@karthikaun](https://github.com/karthikaun) | [thejesh23/capstone-test-project#1](https://github.com/thejesh23/capstone-test-project/pull/1) | Fixed a typo in a greeting script \(a test of the graduation flow\). |
| Thejesh | [@thejesh23](https://github.com/thejesh23) | [python/cpython#162029](https://github.com/python/cpython/pull/162029) | My first CPython fix, in the json module. |
4 changes: 0 additions & 4 deletions graduates/karthikaun.py

This file was deleted.

12 changes: 12 additions & 0 deletions tests/test_check_graduate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_front_page_strip_shows_the_newest_and_links_to_the_wall(tmp_path, monke
monkeypatch.setattr(wall, "added_time", lambda path: int(path.stem[4:])) # user34 is the newest
block = wall.strip(tmp_path)
assert f"**{wall.STRIP_MAX + 5} graduates**" in block and "[See the wall](graduates/)" in block
assert f"Here are the {wall.STRIP_MAX} most recent, newest first." in block
assert block.count("<img ") == wall.STRIP_MAX
assert "user34.png" in block and "user05.png" in block and "user04.png" not in block
assert block.index("user34.png") < block.index("user33.png"), "newest first"
Expand Down Expand Up @@ -206,3 +207,14 @@ def git(*args, when=None):
assert wall.added_time(tmp_path / "early.py") > wall.added_time(tmp_path / "late.py")
block = wall.strip(tmp_path)
assert block.index("early.png") < block.index("late.png"), "merged last, shown first"


def test_the_wall_shows_the_newest_first_and_says_so(tmp_path, monkeypatch):
for login in ("anna", "zed"):
(tmp_path / f"{login}.py").write_text(GOOD.replace('"ada"', f'"{login}"'))
monkeypatch.setattr(wall, "added_time", lambda path: {"anna": 1, "zed": 2}[path.stem]) # zed is the newest
page = wall.render(tmp_path)
assert "**2 graduates**, the most recent first." in page
assert page.index("zed.png") < page.index("anna.png"), "photos: newest first"
assert page.index("[@zed]") < page.index("[@anna]"), "table: newest first"
assert "The most recent is first." in wall.strip(tmp_path)
21 changes: 15 additions & 6 deletions tools/graduates_wall.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def graduates(folder: Path) -> list[Graduate]:
return out


def newest_first(people: list[Graduate]) -> list[Graduate]:
"""The most recently merged graduate first; usernames break ties."""
return sorted(people, key=lambda g: (-g.added, g.login.lower()))


def rows(folder: Path) -> list[str]:
return [
f"| {escape(g.name)} | [@{g.login}](https://github.com/{g.login}) "
f"| [{g.owner}/{g.repo}#{g.number}](https://github.com/{g.owner}/{g.repo}/pull/{g.number}) "
f"| {escape(g.message)} |"
for g in graduates(folder)
for g in newest_first(graduates(folder))
]


Expand All @@ -123,8 +128,8 @@ def render(folder: Path) -> str:
return HEADER + "No graduates yet. You could be the first!\n"
return (
HEADER
+ f"**{count(len(people))}**\n\n"
+ photos(people, 64)
+ f"**{count(len(people))}**, the most recent first.\n\n"
+ photos(newest_first(people), 64)
+ "\n\n| Name | GitHub | Contribution | Message |\n|---|---|---|---|\n"
+ "\n".join(rows(folder))
+ "\n"
Expand All @@ -137,11 +142,15 @@ def strip(folder: Path) -> str:
join = "[Join them](lessons/15-capstone/)"
if not people:
return f"No graduates yet. You could be the first! {join}.\n"
newest = sorted(people, key=lambda g: (-g.added, g.login.lower()))[:STRIP_MAX]
more = f" These are the {STRIP_MAX} most recent." if len(people) > STRIP_MAX else ""
newest = newest_first(people)[:STRIP_MAX]
order = (
f"Here are the {STRIP_MAX} most recent, newest first."
if len(people) > STRIP_MAX
else "The most recent is first."
)
return (
f"**{count(len(people))}** finished the course with a pull request merged in a real open source "
f"project.{more} [See the wall](graduates/) · {join}\n\n" + photos(newest, 48) + "\n"
f"project. {order} [See the wall](graduates/) · {join}\n\n" + photos(newest, 48) + "\n"
)


Expand Down
Loading