oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env python3
2"""Keep the native apps in the web's words where they must match.
3
4Every native string whose key is one of the web's copy keys (chat.card.*,
5work.tl.*, roster.*) must equal copy.go's text for that key, so a merge card
6says exactly what the web says (sync proposal, parity row R-02), and Set
7aside and Undo say what the web's do (D5)."""
8import json, re, sys
9from pathlib import Path
10
11native = Path(__file__).resolve().parents[1]
12strings = json.loads((native / 'scripts/strings.json').read_text())
13copy = (native.parent / 'internal/equipo/copy.go').read_text()
14problems, checked = [], 0
15# Every outcome the web can show for a decision answered here needs native
16# words, or the answered card would silently show none.
17for pattern in (r'chat\.card\.merge_chose_\w+', r'chat\.card\.ships_chose_\w+'):
18 for key in sorted(set(re.findall('"(' + pattern + ')":', copy))):
19 if key not in strings:
20 problems.append(f'{key}: the web has this outcome; native has no words for it')
21for key in sorted(set(re.findall(r'"(work\.reason\.[^"]+)":', copy))):
22 if key not in strings:
23 problems.append(f'{key}: native must carry every reviewed stop reason')
24for key, text in sorted(strings.items()):
25 if not key.startswith(('settings.discard', 'chat.day.today', 'runner.verdict.skipped', 'work.', 'placement.', 'chat.card.', 'chat.paste.', 'chat.attach.', 'work.tl.', 'roster.', 'projects.', 'work.star.', 'api.', 'nav.projects', 'chat.connections.connected', 'chat.connections.dismiss', 'counts.unavailable', 'team.close', 'work.pause.', 'work.reason.', 'work.needs.', 'chat.held.', 'work.hold.', 'work.stage.', 'time.', 'work.hold.run_now', 'work.recover')):
26 continue
27 found = re.findall(r'"' + re.escape(key) + r'":\s*"((?:[^"\\]|\\.)*)"', copy)
28 if len(found) != 1:
29 problems.append(f'{key}: found {len(found)} times in copy.go, expected once'); continue
30 web = json.loads('"' + found[0] + '"').replace('%s', '%@')
31 checked += 1
32 if web != text:
33 problems.append(f'{key}: native says {text!r}, the web says {web!r}')
34for p in problems: print(p)
35if problems: sys.exit(1)
36print(f'{checked} native strings match the web')
37