Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
tools: gen_tables.py --adopt says which tv.json files it wrote before it stopped
xbshengb5099a49b81c
diff --git a/tests/test_gen_tables.py b/tests/test_gen_tables.pyindex adaf83fe6..96cae2e98 100644--- a/tests/test_gen_tables.py+++ b/tests/test_gen_tables.py@@ -421,11 +421,38 @@ diff --git a/examples/README.md b/examples/README.mdpatch.write_text(self.PATCH, encoding="utf-8")code, out = run(root, "--adopt", str(patch))self.assertEqual(code, 2)- self.assertIn("examples/tcl-a/tv.json: the row this PR edits has changed on main", out)+ self.assertIn("examples/tcl-a/tv.json: the row this PR edits has changed on main since", out)self.assertEqual(json.loads((root / "examples/tcl-a/tv.json").read_text())["notes"],"ads off; promos off, second unit")# The new folder in the same PR still gets its tv.json.self.assertTrue((root / "examples/tcl-55l8/tv.json").is_file())+ # And the message says which files that was, above the row it did not apply: the run stops after+ # writing, so a reader who took the whole block as "nothing happened" would leave them behind.+ self.assertIn("These tv.json files are written and stay written:", out)+ self.assertLess(out.index("examples/tcl-55l8/tv.json: new"), out.index("These rows were not applied:"))+ self.assertLess(out.index("These rows were not applied:"),+ out.index("examples/tcl-a/tv.json: the row this PR edits has changed"))+ # Nothing was regenerated from them: the tables still hold the rows they had, and --check says so.+ self.assertNotIn("tcl-55l8", (root / "examples/README.md").read_text(encoding="utf-8"))+ self.assertEqual(run(root, "--check")[0], 1)++ def test_a_patch_it_could_not_apply_at_all_says_so(self):+ # The patch's only row is one main has moved on, so there is nothing written to name - and the+ # message says that instead of letting the reader assume a tv.json appeared somewhere.+ with tempfile.TemporaryDirectory() as tmp:+ root = tree(tmp, [("tcl-a", tv("TCL A", "TCL", notes="ads off; promos off, second unit"))])+ patch = root / "pr.diff"+ patch.write_text("diff --git a/examples/README.md b/examples/README.md\n"+ "@@ -10,3 +10,4 @@\n"+ " | `tcl-a/` | TCL A | Android TV 11 | ads off |\n"+ "+| `tcl-a/` | TCL A | Android TV 11 | ads off; second unit, UK |\n", encoding="utf-8")+ code, out = run(root, "--adopt", str(patch))+ self.assertEqual(code, 2)+ self.assertIn("No tv.json was written.", out)+ self.assertNotIn("written and stay written", out)+ self.assertIn("These rows were not applied:", out)+ self.assertEqual(json.loads((root / "examples/tcl-a/tv.json").read_text())["notes"],+ "ads off; promos off, second unit")if __name__ == "__main__":diff --git a/tests/test_gen_tables_adopt_checkout.py b/tests/test_gen_tables_adopt_checkout.pyindex 61520ae7a..be3e320cb 100644--- a/tests/test_gen_tables_adopt_checkout.py+++ b/tests/test_gen_tables_adopt_checkout.py@@ -11,7 +11,10 @@ saying it had, and then exited 2 on a line that says nothing is written then.`load()` now takes `allow_missing` - the one shape `--adopt` is for, a folder with no `tv.json` yet - and`adopt()` reads the checkout through it, so every file that is there is judged by the rules the tables are-built with, before the first write. A patch is applied whole or not at all.+built with, before the first write. That is the whole of the guard: a row main has moved on stops the run+after the files it could apply are written, so a patch is applied as far as it goes and the rest is named+(tools/gen_tables.py's exit-2 paragraph says what that leaves in the checkout, and+tests/test_gen_tables.py's test_a_row_main_has_changed_since_is_not_overwritten pins it).Every test runs the real script in a subprocess, since the exit status and the lines on stderr are what amaintainer sees; the trees come from tests/test_gen_tables.py, so a valid checkout is built the same waydiff --git a/tools/gen_tables.py b/tools/gen_tables.pyindex 0f5942373..1a9200e09 100644--- a/tools/gen_tables.py+++ b/tools/gen_tables.py@@ -34,7 +34,9 @@ The counts are the card's alt text ("N TV models · B brands · 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; thepicture is not - redraw it before committing), 2 what it was given cannot be read: a tv.json, a marker, or-the path in --root or --adopt (nothing is written then).+the path in --root or --adopt (nothing is written then), or an --adopt row main has changed since the PR+was written: the tv.json files the patch did apply are on disk and the message names them, the tables are+not regenerated, so that row is moved into its tv.json by hand and the script run again."""import argparseimport json@@ -331,11 +333,17 @@ def adopt(root, patch_text):and notes, a README row with the same TV gives readme_os when its OS differs. A folder with no tv.jsongets one. A folder that has one (a PR that edited its row) takes the new tv, os and notes only if therow the PR removed is what its tv.json still says; if main has changed the row since, nothing is- written for it and Problem is raised once the rest are done. Returns [(folder, what happened)].+ written for that folder and Problem is raised once the rest are done. Returns [(folder, what happened)].The tv.json files already in the checkout are read through load(), so one this script cannot use is- named in the words --check names it and Problem is raised before the first write: a patch is applied- whole or not at all, which is what the module's exit-2 line says."""+ named in the words --check names it and Problem is raised before the first write. A row main has moved+ on is the other way it stops, and it stops late: what it could apply is written first, and the message+ lists those files as written rather than as part of the complaint (the module's exit-2 line says what+ that leaves in the checkout: the tables are not regenerated, so the row is fixed by hand and the+ script run again). Calling the patch all-or-nothing, as this docstring once did, was the reader being+ told a failed run left nothing behind - tests/test_gen_tables.py's+ test_a_row_main_has_changed_since_is_not_overwritten pins what it really leaves.+ """lines = patch_text.split("\n")added = [l[1:] if l.startswith("+") else l for l in lines if not l.startswith(("-", " "))]removed = [l[1:] for l in lines if l.startswith("-")]@@ -372,7 +380,17 @@ def adopt(root, patch_text):write_json(folder / "tv.json", data)out.append((name, f"new, brand {brand}" + ("" if brand in known else " (a new brand: check the spelling)")))if stale_rows:- raise Problem("\n".join([f"examples/{n}/tv.json: {what}" for n, what in out] + stale_rows))+ # The files this run did write are said as written, above the rows it did not apply: a maintainer+ # who reads the whole block as "nothing happened" leaves those tv.json files uncommitted, or+ # commits them beside tables that were never regenerated - and the next --check run is the one+ # that says so.+ written = [f"examples/{n}/tv.json: {what}" for n, what in out]+ head = (["These tv.json files are written and stay written:"] + written) if written \+ else ["No tv.json was written."]+ raise Problem("\n".join(head + ["These rows were not applied:"] + stale_rows + [+ "The tables were not regenerated, so README.md and examples/README.md still hold the rows they "+ "had and this checkout now answers --check with 1. Move that row's change into its tv.json by "+ "hand, then run python3 tools/gen_tables.py again."]))return out