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
tests: a folder README's package count is read as a sentence, not a line
xbsheng960bff9140d8
diff --git a/docs/workflows/tv-list.md b/docs/workflows/tv-list.mdindex ec5cefc15..6cd4b568b 100644--- a/docs/workflows/tv-list.md+++ b/docs/workflows/tv-list.md@@ -43,7 +43,9 @@A package count ("The 38 packages that were disabled", "the debloat list disables 71 packages") iscompared with what `tools/disable.sh` would send for the list, so a line added or commented out later movesthe number in the README with it: `tests/test_example_list_count.py` answers- `examples/<folder>/README.md says 12 packages in the debloat.txt row and its debloat.txt carries 8`. Its undo+ `examples/<folder>/README.md says 12 packages in the debloat.txt row and its debloat.txt carries 8`. A+ sentence the page wraps across two lines is still read as one sentence, so a break cannot hide the+ number. Its undois the other: the restore command a README shows passes the same stock launcher as the list's own Undo line,or none where the list passes none, because those two are where an owner looks for the way back and the copythat passes a different package leaves the stock home disabled. `tests/test_folder_undo_agrees.py` names eachdiff --git a/tests/test_example_list_count.py b/tests/test_example_list_count.pyindex 77b98f66c..f17a600ea 100644--- a/tests/test_example_list_count.py+++ b/tests/test_example_list_count.py@@ -20,6 +20,14 @@ stayed green. The words are read the same way the link is: the present tense "dithat names the debloat list or `debloat.txt` itself, and nothing that names another list (a folderwith a `debloat-keep-cast.txt` states its own count about that file).+A sentence is read as a sentence, not as a line: these pages wrap their prose by hand at about 100+characters, so the Haier HRA962X2 README ends one line with "the debloat list" and starts the next with+"disables 40 packages". #2817 commented that list's two stock-home lines out and left it sending 38,+and the words reader - which matched inside one line - saw no claim at all, the way the Hikeen count was+invisible before. Its paragraph is joined before the match and split again where a sentence ends, so a+number still has to sit in the same sentence as the words that name the list: a paragraph that grew a+second sentence about a batch size is not a claim.+The number is compared with the packages tools/disable.sh would actually send, parsed the way thatscript parses a list (a trailing `# comment` is not part of the line, whole-line `#` comments andblank lines are skipped, the first field is the package name). Nothing is copied in: the claim comes@@ -52,11 +60,17 @@ PROSE_WORDS = re.compile()# `1. **Debloated 23 packages** - ad services, app stores, background junk`PROSE_STEP = re.compile(r"\*\*[Dd]ebloated (\d+) packages\*\*")+STEP = "the step that says what was done"+# The two forms a page can wrap by hand, read a sentence at a time (see sentences() below).PROSE = ((PROSE_LINK, "the sentence about the debloat list"),(PROSE_WORDS, "the sentence that names the list in words"),- (PROSE_STEP, "the step that says what was done"),)+# Where one sentence ends and the next begins: the pages carry firmware builds with dots in them+# (`PPR1.180610.011.20220314.`), so only punctuation followed by a space is a boundary.+SENTENCE_END = re.compile(r"(?<=[.!?])\s+")+# A line that opens a list item starts its own paragraph, so a claim is not read across two items.+BULLET = re.compile(r"^(?:[-*+]\s|\d+\.\s)")ROW = "the debloat.txt row"@@ -74,6 +88,51 @@ def packages(list_path):return names+def paragraphs(readme_text):+ """Every paragraph of a README's prose, its wrapped lines joined with one space.++ A page here wraps its sentences by hand, so a claim can be split across two lines. Table rows,+ headings and fenced blocks are left out (they are not sentences, and a row is read on its own), and+ a list item starts a new paragraph, so two bullets are never read as one sentence.+ """+ out, current, fenced = [], [], False++ def flush():+ if current:+ out.append(" ".join(current))+ current.clear()++ for line in readme_text.split("\n"):+ text = line.strip()+ if text.startswith("```"):+ flush()+ fenced = not fenced+ continue+ if fenced:+ continue+ if not text or text.startswith(("#", "|")):+ flush()+ continue+ if BULLET.match(text):+ flush()+ current.append(text)+ flush()+ return out+++def sentences(readme_text):+ """The prose, one sentence at a time: the wrapped lines joined, then split where a sentence ends.++ Reading a sentence and not a line is what makes a hand-wrapped claim readable - and keeping the+ sentence boundary is what stops a paragraph's first sentence from lending its words to a number in+ the second one.+ """+ for paragraph in paragraphs(readme_text):+ for sentence in SENTENCE_END.split(paragraph):+ if sentence.strip():+ yield sentence++def claims(readme_text):"""Every package count the README states for its debloat.txt, as (where it says it, number).@@ -82,7 +141,10 @@ def claims(readme_text):The prose forms can overlap: `The [debloat list](debloat.txt) disables 71 packages` is the linkreader's sentence and the words reader's too, since it names the list both ways. Both capture the- same digits, so a number already read on that line is not read again - one claim, one failure.+ same digits, so a number already read in that sentence is not read again - one claim, one failure.++ The row and the bold step are read line by line, where they are always written; the two prose forms+ are read a sentence at a time, so a sentence the page wrapped by hand is one claim."""found = []for line in readme_text.split("\n"):@@ -92,9 +154,12 @@ def claims(readme_text):if count:found.append((ROW, int(count.group(1))))continue+ for match in PROSE_STEP.finditer(line):+ found.append((STEP, int(match.group(1))))+ for sentence in sentences(readme_text):read = []for pattern, where in PROSE:- for match in pattern.finditer(line):+ for match in pattern.finditer(sentence):span = match.span(1)if any(span[0] < other[1] and other[0] < span[1] for other in read):continue@@ -181,6 +246,63 @@ class CountReaderTest(unittest.TestCase):text = "launcher is the stock Home. The debloat list disables 26 packages.\n"self.assertEqual(claims(text), [("the sentence that names the list in words", 26)])+ def test_a_sentence_the_page_wrapped_by_hand_is_read(self):+ # The Haier HRA962X2 README's shape: `the debloat list` ends one line and the count opens the+ # next, so a reader that matched inside one line saw no claim while the list lost two packages.+ text = (+ "firmware PPR1.180610.011.20220314. The stock Home is Youku's launcher; the debloat list\n"+ "disables 40 packages: YunOS ad and telemetry services, the Aligenie voice stack.\n"+ )+ self.assertEqual(claims(text), [("the sentence that names the list in words", 40)])++ def test_a_wrapped_link_sentence_is_read_once(self):+ text = (+ "The [debloat\n"+ "list](debloat.txt) disables 71 packages.\n"+ )+ self.assertEqual(claims(text), [("the sentence about the debloat list", 71)])++ def test_a_wrapped_sentence_about_another_file_is_not_read(self):+ # The wrap must not turn `debloat-keep-cast.txt` into this folder's own list.+ text = "The cast receivers live in\n`debloat-keep-cast.txt`, which disables 3 packages.\n"+ self.assertEqual(claims(text), [])++ def test_a_number_in_the_next_sentence_is_not_read(self):+ # Joining the lines must not let one sentence's words reach the next one's number.+ text = (+ "This page describes the debloat list in the next paragraph\n"+ "and says nothing about its size. It disables 40 packages of the 41 the firmware ships.\n"+ )+ self.assertEqual(claims(text), [])++ def test_a_wrapped_bullet_is_read(self):+ text = "- The debloat list\n disables 12 packages, all of them telemetry.\n"+ self.assertEqual(claims(text), [("the sentence that names the list in words", 12)])++ def test_two_bullets_are_not_one_sentence(self):+ # A claim's words in one item and a number in the next is not a claim about the list.+ text = (+ "- The debloat list is described below.\n"+ "- **Debloated 23 packages** and left the rest alone.\n"+ )+ self.assertEqual(claims(text), [("the step that says what was done", 23)])++ def test_a_table_row_is_not_joined_into_a_sentence(self):+ text = (+ "The debloat list\n"+ "| `README.md` | the 40 packages explained |\n"+ "disables 40 packages.\n"+ )+ self.assertEqual(claims(text), [])++ def test_a_fenced_block_is_not_read(self):+ text = (+ "```\n"+ "The debloat list disables 40 packages.\n"+ "```\n"+ )+ self.assertEqual(claims(text), [])+def test_the_linked_sentence_is_read_once(self):# Both readers match `The [debloat list](debloat.txt) disables 71 packages`; the number is one# claim, so a stale count is one failure and not two.