# Before deleting ~/.config/credentials (operator's go, 2026-10-17): every key in it must be in the store with an equal # value. Compares in memory; prints names and MATCH / MISSING / DIFFERENT only, never a value. import os, re, sys sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/cc-secrets") from ccsec import store vals = store.load_all() bad = 0 lines = open(os.path.expanduser("~/.config/credentials"), encoding="utf-8").read().split("\n") for n, line in enumerate(lines, 1): s = line.strip() if not s or s.startswith("#"): continue m = re.match(r"^(export\s+)?([A-Za-z_][A-Za-z0-9_-]*)=(.*)$", s) if not m: print("line %d: NOT a KEY=VALUE line (%d chars)" % (n, len(s))); bad += 1; continue name = m.group(2).replace("-", "_") try: v = store.unwrap(m.group(3), "line %d" % n) except store.StoreError as e: print("line %d %s: cannot unwrap (%s)" % (n, name, e)); bad += 1; continue state = "MATCH" if vals.get(name) == v else ("MISSING" if name not in vals else "DIFFERENT") bad += state != "MATCH" print("%-24s %s" % (name, state)) print("lines %d, problems %d" % (len(lines), bad))