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 refuses a non-string tv or notes by name, and --font works from any folder
Mazin Kanugaf69cfebcb0bf
diff --git a/tests/test_gen_tables.py b/tests/test_gen_tables.pyindex eef0acf5d..232d962e0 100644--- a/tests/test_gen_tables.py+++ b/tests/test_gen_tables.py@@ -3,8 +3,8 @@Every list PR used to add rows to the same two tables, so each merge made the other open list PRs conflict.Now a PR adds only its folder and the script writes the rows. These tests run it on this repository (runningit twice changes nothing, both tables come out in the same alphabetical order) and on small trees written here-(a new folder gets its rows, the brand line counts right, a bad tv.json is refused, an old-style PR's rows-become a tv.json).+(a new folder gets its rows, the brand line counts right, a bad tv.json is refused, a --font path given from+another folder reaches the card scripts, an old-style PR's rows become a tv.json).Run from the repository root: python3 -m unittest discover -s tests -v"""@@ -12,6 +12,8 @@ import ioimport jsonimport osimport re+import shutil+import subprocessimport sysimport tempfileimport unittest@@ -19,8 +21,10 @@ from contextlib import redirect_stderr, redirect_stdoutfrom pathlib import PathROOT = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(ROOT / "tests"))sys.path.insert(0, str(ROOT / "tools"))import gen_tables # noqa: E402 (needs tools/ on the path first)+from test_card_font_argument import shadow_dir # noqa: E402 (a PIL that cannot be imported)START = "<!-- {}:start: generated -->"END = "<!-- {}:end -->"@@ -229,7 +233,10 @@ class GeneratorTest(unittest.TestCase):(tv("X", "X", colour="red"), "unknown key"),(tv("X", "X", notes="a | b"), "split the table cell"),(tv("X\n", "X"), "one line"),- (tv("X", "X", notes="[note](../docs/devices/none.md)"), "leads nowhere")]+ (tv("X", "X", notes="[note](../docs/devices/none.md)"), "leads nowhere"),+ # Not a string: refused by name, where the link check used to end in a TypeError (exit 1).+ (tv("X", "X", notes=["a", "b"]), '"notes" must be'),+ (tv(["X"], "X"), '"tv" must be')]for data, message in cases:with self.subTest(message=message), tempfile.TemporaryDirectory() as tmp:root = tree(tmp, [("x-1", data)])@@ -252,6 +259,26 @@ class GeneratorTest(unittest.TestCase):gen_tables.render(root)+class FontTest(unittest.TestCase):+ def test_a_font_path_from_another_folder_reaches_the_card_scripts(self):+ # --font is checked from where the script is run, and the card scripts run in the checkout.+ with tempfile.TemporaryDirectory() as tmp:+ (Path(tmp) / "repo").mkdir()+ root = tree(Path(tmp) / "repo", [("tcl-a", tv("TCL A", "TCL"))])+ # The real script, whose counts this tree changes, so --font hands it the font.+ shutil.copy(ROOT / "tools" / "readme_stats.py", root / "tools" / "readme_stats.py")+ caller = Path(tmp) / "caller"+ caller.mkdir()+ (caller / "Fredoka.ttf").write_bytes(b"")+ (Path(tmp) / "no-pillow").mkdir()+ env = dict(os.environ, PYTHONPATH=shadow_dir(Path(tmp) / "no-pillow"))+ done = subprocess.run([sys.executable, str(ROOT / "tools" / "gen_tables.py"), "--root", str(root),+ "--font", "Fredoka.ttf"], cwd=caller, env=env, capture_output=True, text=True)+ self.assertNotIn("cannot open the font at", done.stderr, "the card script looked for the font in the checkout")+ # Pillow is hidden, so the script stops at its Pillow line: it got past the font.+ self.assertIn("needs Pillow", done.stderr, done.stderr)++class AdoptTest(unittest.TestCase):"""--adopt: an open PR from before the script carries its rows in the tables, not in a tv.json."""diff --git a/tools/gen_tables.py b/tools/gen_tables.pyindex 514995518..4f53b0443 100644--- a/tools/gen_tables.py+++ b/tools/gen_tables.py@@ -91,7 +91,9 @@ def load(root):if "readme_os" in data:problems += check_cell(where, "readme_os", data["readme_os"])for key in ("tv", "notes"):- for target in LINK.findall(data.get(key) or ""):+ value = data.get(key)+ # A value that is not a string has no link to read, and check_cell has already said it is wrong.+ for target in LINK.findall(value if isinstance(value, str) else ""):if re.match(r"^(https?:|mailto:|#)", target):continueif not (root / "examples" / target.split("#")[0]).exists():@@ -343,8 +345,10 @@ def main(argv=None):return 2if "tools/readme_stats.py" in changed:if a.font:+ # The font was checked from where this runs; the scripts run in the checkout, so hand them the full path.+ font = str(Path(a.font).resolve())for script, out in (("tools/readme_stats.py", "docs/stats.png"), ("tools/readme_card.py", "docs/card.jpg")):- subprocess.run([sys.executable, script, a.font, out], cwd=root, check=True)+ subprocess.run([sys.executable, script, font, out], cwd=root, check=True)changed += ["docs/stats.png", "docs/card.jpg"]else:print("A count changed: redraw docs/stats.png and docs/card.jpg (--font Fredoka.ttf, or "