Finish the wonderland: System told truthfully, in eight tabs instead of ten
Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
@@ -43,6 +43,8 @@ CATEGORY = re.compile(
|
||||
r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)",\s*icon:\s*"[^"]*",\s*tabs:\s*\[([^\]]*)\]\s*\}',
|
||||
re.S)
|
||||
TAB = re.compile(r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)"\s*\}')
|
||||
HIDDEN = re.compile(
|
||||
r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)",\s*category:\s*"([a-z-]+)"\s*\}')
|
||||
|
||||
|
||||
class SchemaError(RuntimeError):
|
||||
@@ -61,9 +63,11 @@ def read_titles():
|
||||
if not block:
|
||||
raise SchemaError("could not find the categories array in SettingsRoutes.qml")
|
||||
titles = {}
|
||||
labels = {}
|
||||
read = 0
|
||||
for page, label, tabs in CATEGORY.findall(block.group(1)):
|
||||
found = TAB.findall(tabs)
|
||||
labels[page] = label
|
||||
read += 1 + len(found)
|
||||
if found:
|
||||
titles.update({tab: f"{label} › {tab_label}" for tab, tab_label in found})
|
||||
@@ -77,6 +81,19 @@ def read_titles():
|
||||
raise SchemaError(
|
||||
f"read {read} of the {declared} pages in SettingsRoutes.qml; the "
|
||||
"categories array no longer looks the way this reader expects")
|
||||
|
||||
# Leaves that are routable but draw no tab -- the manual -- are declared
|
||||
# outside the categories array, because the reader above requires each
|
||||
# category to end `tabs: [...] }` and accounts for every `page:` inside it.
|
||||
# They are still pages somebody lands on, so they are still named here.
|
||||
hidden = re.search(r"readonly property var hiddenLeaves: \[(.*?)\n \]", text, re.S)
|
||||
if hidden:
|
||||
found = HIDDEN.findall(hidden.group(1))
|
||||
if len(found) != len(re.findall(r'\bpage:\s*"', hidden.group(1))):
|
||||
raise SchemaError(
|
||||
"the hiddenLeaves array no longer looks the way this reader expects")
|
||||
for page, label, category in found:
|
||||
titles[page] = f"{labels.get(category, category)} › {label}"
|
||||
return titles
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user