Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tools: gen_tables.py writes README.de.md's brand grid and counts

xbshenga87d3e851298
diff --git a/README.de.md b/README.de.md
index 797e5095d..8d1d3caac 100644
--- a/README.de.md
+++ b/README.de.md
@@ -128,20 +128,20 @@ meisten Listen, jede mit ihren Modellen auf der Website verlinkt:
| | | | | | |
|---|---|---|---|---|---|
-| [TCL](https://cleanyour.tv/tvs?q=TCL) · 76 | [Sony](https://cleanyour.tv/tvs?q=Sony) · 40 | [Xiaomi](https://cleanyour.tv/tvs?q=Xiaomi) · 32 | [Philips](https://cleanyour.tv/tvs?q=Philips) · 18 | [Skyworth](https://cleanyour.tv/tvs?q=Skyworth) · 14 | [Hisense](https://cleanyour.tv/tvs?q=Hisense) · 11 |
-| [Amazon Fire TV](https://cleanyour.tv/tvs?q=Amazon%20Fire%20TV) · 7 | [Panasonic](https://cleanyour.tv/tvs?q=Panasonic) · 6 | [BenQ](https://cleanyour.tv/tvs?q=BenQ) · 5 | [SHARP](https://cleanyour.tv/tvs?q=SHARP) · 5 | [JVC](https://cleanyour.tv/tvs?q=JVC) · 4 | [OnePlus](https://cleanyour.tv/tvs?q=OnePlus) · 4 |
+| [TCL](https://cleanyour.tv/tvs?q=TCL) · 76 | [Sony](https://cleanyour.tv/tvs?q=Sony) · 40 | [Xiaomi](https://cleanyour.tv/tvs?q=Xiaomi) · 34 | [Philips](https://cleanyour.tv/tvs?q=Philips) · 18 | [Skyworth](https://cleanyour.tv/tvs?q=Skyworth) · 15 | [Hisense](https://cleanyour.tv/tvs?q=Hisense) · 11 |
+| [Amazon Fire TV](https://cleanyour.tv/tvs?q=Amazon%20Fire%20TV) · 7 | [Panasonic](https://cleanyour.tv/tvs?q=Panasonic) · 6 | [SHARP](https://cleanyour.tv/tvs?q=SHARP) · 6 | [BenQ](https://cleanyour.tv/tvs?q=BenQ) · 5 | [JVC](https://cleanyour.tv/tvs?q=JVC) · 4 | [OnePlus](https://cleanyour.tv/tvs?q=OnePlus) · 4 |
| [Thomson](https://cleanyour.tv/tvs?q=Thomson) · 4 | [Google](https://cleanyour.tv/tvs?q=Google) · 3 | [Grundig](https://cleanyour.tv/tvs?q=Grundig) · 3 | [Haier](https://cleanyour.tv/tvs?q=Haier) · 3 | [Motorola](https://cleanyour.tv/tvs?q=Motorola) · 3 | [NVIDIA Shield](https://cleanyour.tv/tvs?q=NVIDIA%20Shield) · 3 |
| [RCA](https://cleanyour.tv/tvs?q=RCA) · 3 | [Redmi](https://cleanyour.tv/tvs?q=Redmi) · 3 | [Toshiba](https://cleanyour.tv/tvs?q=Toshiba) · 3 | [Vu](https://cleanyour.tv/tvs?q=Vu) · 3 | [CHiQ](https://cleanyour.tv/tvs?q=CHiQ) · 2 | [EKO](https://cleanyour.tv/tvs?q=EKO) · 2 |
| [FFalcon](https://cleanyour.tv/tvs?q=FFalcon) · 2 | [Hitachi](https://cleanyour.tv/tvs?q=Hitachi) · 2 | [Insignia Fire TV](https://cleanyour.tv/tvs?q=Insignia%20Fire%20TV) · 2 | [Kalley](https://cleanyour.tv/tvs?q=Kalley) · 2 | [Kogan](https://cleanyour.tv/tvs?q=Kogan) · 2 | [Nokia](https://cleanyour.tv/tvs?q=Nokia) · 2 |
<details>
-<summary>+49 more brands and 14 projector brands</summary>
+<summary>+53 more brands and 14 projector brands</summary>
**onn** 2 · **RockTek** 2 · **Sankey** 2 · **Sber** 2 · **Vidda** 2 ·
Acer · AiPro2K · AIWA · AQUA · Artel · ASUS · Beko · BGH · Caxium · Cecotec · Challenger · Compac · Dcolor · Dialog ·
-DYON · Freebox · Home+ · INCLO · Karbonn · KTC · Liberton · Lumio · Master-G · MTC · Next · Noblex · OK. · OPPO ·
-Panavox · PEAQ · Polytron · PPTV · PRISM+ · SANYO · Seleco · Super General · Síragon · Tele System · TiVo · Tornado ·
-Turkcell · Tuvio · Verizon · Vision ·
+DYON · Freebox · Home+ · Impex · INCLO · Karbonn · Koryo · KTC · Liberton · Lumio · Master-G · MECOOL · MTC · Next ·
+Noblex · OK. · OPPO · Panavox · PEAQ · Polytron · PPTV · PRISM+ · Prosonic · SANYO · Seleco · Super General · Síragon ·
+Tele System · TiVo · Tornado · Turkcell · Tuvio · Verizon · Vision ·
Alwtniet, Anker Nebula, BYINTEK, Epson, Formovie, Gadnic, HOTACK, HY320, JMGO, Magcubic, Portronics, Stellamore, Wanbo and XGIMI projectors
</details>
diff --git a/docs/workflows/tv-list.md b/docs/workflows/tv-list.md
index 3d0230171..a27bba0a8 100644
--- a/docs/workflows/tv-list.md
+++ b/docs/workflows/tv-list.md
@@ -28,9 +28,10 @@
for a set whose row there should read shorter than the same set's row in `examples/README.md` - that table
has room for `Google TV launcher on Android TV 11`, the short one for `Google TV 11`.
`tests/test_examples.py` checks the file.
-5. Change nothing outside the folder. The tables in `examples/README.md` and `README.nl.md`, the brand grid and the
- counts (the `TV models` number in the card's alt text) are generated from every `tv.json` by
- `tools/gen_tables.py`, which a maintainer runs after merging; CI compares them only on `main`.
+5. Change nothing outside the folder. The tables in `examples/README.md` and `README.nl.md`, the brand grid in
+ `README.md`, `README.nl.md` and `README.de.md`, and the counts (the `TV models` number in the card's alt text)
+ are generated from every `tv.json` by `tools/gen_tables.py`, which a maintainer runs after merging; CI compares
+ them only on `main`.
6. A `README.md` for TV-specific notes and a `config.json` with the dock are welcome in the folder. Do not add
install or restore scripts, Private DNS or AdGuard setup, or `pm uninstall` steps: the folder only
disables, and `tools/disable.sh` and `tools/restore.sh` do the rest.
diff --git a/tests/test_gen_tables_translated_counts.py b/tests/test_gen_tables_translated_counts.py
index 7f85dc138..7d37e8041 100644
--- a/tests/test_gen_tables_translated_counts.py
+++ b/tests/test_gen_tables_translated_counts.py
@@ -11,6 +11,12 @@ TRANSLATIONS is now {page: the three words that page states its counts in}, so a
its own numbers moved with its grid, and this file reads the mapping: each page it names must state those
three words in its card's alt text, one triple, and must be what render() gives back for it.
+The mapping is also the whole list of pages the script writes, so a translation cannot copy the brand block
+by hand and be left out of it: README.de.md did exactly that when the German page landed, and its grid said
+"Xiaomi · 32" and "+49 more brands" over 97 brands while README.md said 34 and +53 - the block's own header
+says it is generated, and no run touched it. One test here walks the checkout for the markers and holds
+every page that carries them to being written.
+
Run from the repository root: python3 -m unittest discover -s tests -v
"""
import re
@@ -58,12 +64,32 @@ oude merkregel
LISTS = [("acme-a", tv("Acme A", "Acme")), ("acme-b", tv("Acme B", "Acme")), ("bolt-c", tv("Bolt C", "Bolt"))]
+# The German page's card, as README.de.md has it: the same three counts in German, then the launcher's size,
+# which is not one of them and does not move. No short TV table - that page has the brand block only.
+DE = f"""# Titel
+
+<a href="docs/PRESS.md"><img src="docs/card.jpg" alt="316 TV-Modelle · 89 Marken · 28 Sprachen · Launcher
+mit 523 KB. Erwähnt in TechCrunch." width="800"></a>
+
+Eine gewöhnliche deutsche Zeile, die nicht von diesem Generator stammt.
+
+| **28 Sprachen** | Folgt der Sprache des Fernsehers. |
+| **Themes** | Hintergrund und Aufteilung aus einer `config.json`. |
+
+{START.format("tv-brands")}
+
+alte Markenzeile
+
+{END.format("tv-brands")}
+"""
+
-def checkout(tmp, dutch=NL):
- """The fake checkout test_gen_tables.py builds, with a README.nl.md beside its README.md."""
+def checkout(tmp, dutch: str | None = NL, german: str | None = DE):
+ """The fake checkout test_gen_tables.py builds, with the translated READMEs beside its README.md."""
root = tree(tmp, LISTS)
- if dutch is not None:
- (root / "README.nl.md").write_text(dutch, encoding="utf-8")
+ for page, text in (("README.nl.md", dutch), ("README.de.md", german)):
+ if text is not None:
+ (root / page).write_text(text, encoding="utf-8")
return root
@@ -146,6 +172,44 @@ class TranslatedCountsTest(unittest.TestCase):
root = checkout(tmp, dutch=None)
self.assertNotIn("README.nl.md", self.render(root))
+ def test_each_translated_page_states_the_numbers_in_its_own_words(self):
+ # Two pages in the mapping, two sets of words: the Dutch one must not take the German words or the
+ # other way round, which is what one shared triple would do.
+ with tempfile.TemporaryDirectory() as tmp:
+ root = checkout(tmp)
+ rendered = self.render(root)
+ self.assertIn("3 tv-modellen · 2 merken · 3 talen · ", rendered["README.nl.md"])
+ self.assertIn("| **3 talen** |", rendered["README.nl.md"])
+ self.assertIn("3 TV-Modelle · 2 Marken · 3 Sprachen · ", rendered["README.de.md"])
+ self.assertIn("| **3 Sprachen** |", rendered["README.de.md"])
+ self.assertNotIn("Marken", rendered["README.nl.md"])
+ self.assertNotIn("merken", rendered["README.de.md"])
+
+ def test_the_german_page_keeps_what_the_generator_does_not_own(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = checkout(tmp)
+ german = self.render(root)["README.de.md"]
+ self.assertIn("Launcher\nmit 523 KB", german)
+ self.assertIn("Eine gewöhnliche deutsche Zeile, die nicht von diesem Generator stammt.", german)
+ self.assertIn("| **Themes** | Hintergrund und Aufteilung aus einer `config.json`. |", german)
+
+ def test_a_README_de_that_is_not_there_is_not_written(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = checkout(tmp, german=None)
+ rendered = self.render(root)
+ self.assertNotIn("README.de.md", rendered)
+ self.assertIn("README.nl.md", rendered)
+
+ def test_both_translated_pages_get_the_brand_block_beside_their_counts(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ root = checkout(tmp)
+ rendered = self.render(root)
+ for page in ("README.nl.md", "README.de.md"):
+ with self.subTest(page=page):
+ block = section(rendered[page], "tv-brands")
+ self.assertIn("[Acme](https://cleanyour.tv/tvs?q=Acme) · 2", " ".join(block))
+ self.assertNotIn("alte Markenzeile", block)
+
def test_the_brand_block_is_written_beside_the_counts(self):
# The point of moving the numbers: the grid under them is generated from every tv.json.
with tempfile.TemporaryDirectory() as tmp:
@@ -188,6 +252,23 @@ class ThisRepositoryTest(unittest.TestCase):
with self.subTest(page=page):
self.assertEqual((ROOT / page).read_text(encoding="utf-8"), rendered[page])
+ def test_every_page_that_carries_the_brand_block_is_written(self):
+ # The block's header says it is generated, so a page that carries it has to be in the list this
+ # script writes: README.de.md copied it by hand and was left out, and its grid said "Xiaomi · 32"
+ # and "+49 more brands" over 97 brands. A translation that copies the block next is held here.
+ pages, marker = [], "<!-- tv-brands:start"
+ for path in sorted(ROOT.glob("README*.md")):
+ if marker in path.read_text(encoding="utf-8"):
+ pages.append(path.name)
+ self.assertLessEqual({"README.md", "README.nl.md", "README.de.md"}, set(pages),
+ f"the brand block's marker was not found where this test expects it: {pages}")
+ written = set(gen_tables.OWNED) | set(gen_tables.TRANSLATIONS)
+ for page in pages:
+ with self.subTest(page=page):
+ self.assertIn(page, written,
+ f"{page} carries the brand block but tools/gen_tables.py never rewrites it: "
+ f"add it to TRANSLATIONS with the three words its counts are stated in")
+
def test_the_walk_reads_this_checkout(self):
entries = gen_tables.load(ROOT)
self.assertGreaterEqual(len(entries), 300)
diff --git a/tools/gen_tables.py b/tools/gen_tables.py
index 014be811b..2cfe03eb0 100644
--- a/tools/gen_tables.py
+++ b/tools/gen_tables.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""Writes the TV tables, the brand grid and the counts from each examples/<folder>/tv.json.
- gen_tables.py [--root DIR] rewrite README.md, README.nl.md, examples/README.md and
- tools/readme_stats.py
+ gen_tables.py [--root DIR] rewrite README.md, the translated READMEs that carry its brand
+ block, examples/README.md and tools/readme_stats.py
gen_tables.py --check write nothing; exit 1 when a file is out of date
gen_tables.py --font Fredoka.ttf also redraw docs/stats.png and docs/card.jpg if a count moved
gen_tables.py --adopt PATCH write tv.json for folders that have none, from the table rows
@@ -26,9 +26,9 @@ folders in the same order, alphabetical by "tv" (case ignored), so a brand's mod
The full table lives in examples/README.md between <!-- tv-table:start ... --> and <!-- tv-table:end -->.
README.md has no table of its own: its brand grid (the TOP brands with the most lists, linked to the site's
search, and the rest in a <details>) sits between <!-- tv-brands:start ... --> and <!-- tv-brands:end -->.
-README.nl.md carries the same brand block and the same counts in its own words ("N tv-modellen · B merken ·
-L talen · "), and a README that still has tv-table markers gets the short table there too. Everything outside
-the markers is hand-written.
+README.nl.md and README.de.md carry the same brand block and the same counts in their own words ("N
+tv-modellen · B merken · L talen · " and "N TV-Modelle · B Marken · L Sprachen · "), and a README that still
+has tv-table markers gets the short table there too. Everything outside the markers is hand-written.
The counts are the card's alt text ("N TV models · B brands · L languages · "), the "| **L languages** |"
feature row and STATS in tools/readme_stats.py. Exit codes: 0 up to date (or written), 1 out of date
(--check), or a count moved and --font could not draw one of the pictures (the tables are written; the
@@ -240,8 +240,12 @@ OWNED = ("README.md", "examples/README.md", "tools/readme_stats.py")
# to move with it: README.nl.md was added to this script as it stood and said "316 tv-modellen · 89
# merken · 28 talen" over a grid built from 345 lists in 93 brands, because counts() only knew the
# English words. A page listed here without its words would drift the same way, so
-# tests/test_gen_tables_translated_counts.py reads them.
-TRANSLATIONS = {"README.nl.md": ("tv-modellen", "merken", "talen")}
+# tests/test_gen_tables_translated_counts.py reads them - and holds every page that carries the markers to
+# being written, which is how README.de.md came here: it copied the block by hand when the German page
+# landed, so its grid said "Xiaomi · 32" and "+49 more brands" over 97 brands while README.md said 34 and
+# +53, and no run moved it.
+TRANSLATIONS = {"README.nl.md": ("tv-modellen", "merken", "talen"),
+ "README.de.md": ("TV-Modelle", "Marken", "Sprachen")}
def readme(text, entries, root, path, words=WORDS):