From a89a57bb10b9c911cf8a92b1d660fcfc772e5d84 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 28 Sep 2026 13:19:54 +1300 Subject: [PATCH] qet-mcp: a symbol's own texts are not free texts on the folio qet_diff's texts, shapes and pictures sections collected every , and under a folio with iter(). Symbols in older files carry their own texts, so those were counted as the folio's free texts: schema_indus.qet folio 1 showed 124 where QElectroTech has 2, and editing one of those symbol texts would have been reported as a free text changing. Only the folio's direct , and children are read now. Shapes and pictures have no nested copies in the shipped examples; they are changed too so the three stay alike. Found by comparing the tools' answers with QElectroTech's own lists over the shipped examples. Co-Authored-By: Claude Opus 5.5 --- misc/qet-mcp/qet_mcp.py | 10 +++++++--- misc/qet-mcp/test_qet_mcp.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/misc/qet-mcp/qet_mcp.py b/misc/qet-mcp/qet_mcp.py index 1c557067c..036d0c452 100755 --- a/misc/qet-mcp/qet_mcp.py +++ b/misc/qet-mcp/qet_mcp.py @@ -329,13 +329,17 @@ def _extras(root: ET.Element) -> dict: for n, d in _folios(root): folios[n] = {f: d.get(f, "") for f in _FOLIO_FIELDS} - for t in d.iter("input"): + # The folio's own items only: direct children of its , + # and . Symbols in older files carry their own + # texts, which iter() would count as free texts + # (122 extra in schema_indus.qet). + for t in d.findall("inputs/input"): texts.append(record( t, {"folio": n, "x": t.get("x", ""), "y": t.get("y", ""), "text": _plain_text(t.get("text", ""))}, {"rotation": t.get("rotation", "0"), "font": t.get("font", ""), "color": t.get("color", "")})) - for sh in d.iter("shape"): + for sh in d.findall("shapes/shape"): pen, brush = sh.find("pen"), sh.find("brush") shapes.append(record( sh, {"folio": n, "type": sh.get("type", ""), @@ -347,7 +351,7 @@ def _extras(root: ET.Element) -> dict: "fill": (brush.get("color", "") if brush is not None and brush.get("style", "") != "NoBrush" else "none"), "rotation": sh.get("rotation", "0")})) - for im in d.iter("image"): + for im in d.findall("images/image"): images.append(record( im, {"folio": n, "x": im.get("x", ""), "y": im.get("y", "")}, {"scale": im.get("size", ""), "rotation": im.get("rotation", "")})) diff --git a/misc/qet-mcp/test_qet_mcp.py b/misc/qet-mcp/test_qet_mcp.py index f0827225b..15bf8a0bd 100644 --- a/misc/qet-mcp/test_qet_mcp.py +++ b/misc/qet-mcp/test_qet_mcp.py @@ -750,6 +750,22 @@ class Diff(unittest.TestCase): self.assertFalse(d[k]["added"] or d[k]["removed"] or d[k]["changed"]) self.assertEqual(d["folios"]["changed"], []) + def test_a_symbols_own_texts_are_not_free_texts(self): + """Symbols in older files carry their own texts; + counting them made schema_indus.qet show 124 free texts where + QElectroTech has 2.""" + d = self.dir + a, b = d / "sym_a.qet", d / "sym_b.qet" + body = ('' + '' + '' + '') + a.write_text(body.replace("{t}", "inside")) + b.write_text(body.replace("{t}", "changed inside")) + t = m.tool_diff(str(a), str(b))["texts"] + self.assertEqual((t["before"], t["after"], t["added"], t["removed"], t["changed"]), + (1, 1, [], [], [])) + def test_edited_text_reads_as_removed_plus_added(self): a = self.project("a.qet", texts=[(1, 2, "note")]) b = self.project("b.qet", texts=[(1, 2, "note EDITED")])