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
Address review feedback
Mohamed Emad0efaf0a1c91e
diff --git a/tests/test_match.py b/tests/test_match.pyindex 620106b90..ee5897e64 100644--- a/tests/test_match.py+++ b/tests/test_match.py@@ -14,6 +14,7 @@ import subprocessimport sysimport tempfileimport unittest+from unittest import mockROOT = Path(__file__).resolve().parent.parentsys.path.insert(0, str(ROOT / "tools"))@@ -135,6 +136,31 @@ class TallyTest(MatchCase):match.tally(["com.example.ads"], self.examples)self.assertIn("no */debloat.txt", str(caught.exception.code))+ def test_a_list_that_is_a_directory_stops_the_whole_tally(self):+ self.add_list("a", "com.example.ads\n")+ bad = self.examples / "b" / "debloat.txt"+ bad.mkdir(parents=True)+ with self.assertRaises(SystemExit) as caught:+ match.tally(["com.example.ads"], self.examples)+ self.assertIn("could not read", str(caught.exception.code))+ self.assertIn(str(bad), str(caught.exception.code))++ def test_a_list_that_cannot_be_read_stops_the_whole_tally(self):+ self.add_list("a", "com.example.ads\n")+ bad = self.add_list("b", "com.example.ads\n")+ real_read_text = Path.read_text++ def read_text(path, *args, **kwargs):+ if path == bad:+ raise PermissionError(13, "Permission denied", str(path))+ return real_read_text(path, *args, **kwargs)++ with mock.patch.object(Path, "read_text", read_text):+ with self.assertRaises(SystemExit) as caught:+ match.tally(["com.example.ads"], self.examples)+ self.assertIn(str(bad), str(caught.exception.code))+ self.assertIn("Permission denied", str(caught.exception.code))+class MainTest(MatchCase):def run_main(self, *args):@@ -219,6 +245,29 @@ class CommandLineTest(MatchCase):self.assertNotIn("Traceback", result.stderr)self.assertEqual("", result.stdout)+ def test_a_list_that_is_a_directory_exits_2_without_a_traceback(self):+ self.add_list("a", "com.example.ads\n")+ (self.examples / "b" / "debloat.txt").mkdir(parents=True)+ packages = self.write("p.txt", "package:com.example.ads\n")+ result = self.run_script(str(packages), "--examples", str(self.examples))+ self.assertEqual(2, result.returncode, result.stdout + result.stderr)+ self.assertNotIn("Traceback", result.stderr)+ self.assertIn("could not read", result.stderr)+ self.assertEqual("", result.stdout)++ def test_a_dangling_list_symlink_exits_2_without_a_traceback(self):+ folder = self.examples / "a"+ folder.mkdir()+ try:+ (folder / "debloat.txt").symlink_to(self.base / "gone.txt")+ except (OSError, NotImplementedError) as e:+ self.skipTest(f"cannot create a symlink here: {e}")+ packages = self.write("p.txt", "package:com.example.ads\n")+ result = self.run_script(str(packages), "--examples", str(self.examples))+ self.assertEqual(2, result.returncode, result.stdout + result.stderr)+ self.assertNotIn("Traceback", result.stderr)+ self.assertEqual("", result.stdout)+def test_the_checkouts_own_examples_are_read_by_default(self):packages = self.write("p.txt", "package:com.example.unlikely.to.exist\n")result = self.run_script(str(packages))diff --git a/tools/match.py b/tools/match.pyindex f0ce203f7..e2c613548 100644--- a/tools/match.py+++ b/tools/match.py@@ -12,7 +12,8 @@ says.It reads files only: no TV, no ADB client, nothing written. It ranks nothing and suggests no list; thecounts are what the lists say, not a verdict for this TV.-Exit codes: 0 the table was printed, 2 the packages file or the examples folder could not be read.+Exit codes: 0 the table was printed, 2 the packages file, the examples folder or a list in it could not+be read."""import argparsefrom collections import Counter@@ -83,7 +84,12 @@ def tally(packages, examples):disabled, commented = Counter(), Counter()notes = {name: Counter() for name in packages}for path in lists:- off, kept = read_list(path.read_text(encoding="utf-8-sig", errors="replace"))+ try:+ text = path.read_text(encoding="utf-8-sig", errors="replace")+ except OSError as e:+ # One unreadable list stops the whole tally: partial counts would read as the real ones.+ raise SystemExit(f"could not read {path} ({e.strerror or e}): no counts printed")+ off, kept = read_list(text)for counter, entries in ((disabled, off), (commented, kept)):for name, note in entries.items():if name not in wanted: