#!/usr/bin/env python3 """Read a compiled NIBArchive and print its objects, keys and values. WHY THIS EXISTS: a nib is the arbiter for what an application actually asked for. Reasoning about our decoder cannot settle a question the archive answers directly, and one round of that cost a whole boolean polarity: NSNIBArchiveUnarchiver had value type 4 as true and 5 as false, the format has them the other way round, and every boolean in every nib in this system decoded inverted. ONE KEY CANNOT SETTLE A POLARITY, THE WHOLE ARCHIVE CAN. Dump every boolean and ask which reading describes a nib a person would author: 21 controls enabled and 23 not refusing first responder, or every control in the window disabled. python3 scripts/nibdump.py [class name substring] Format: the magic "NIBArchive", ten little-endian uint32 counts and offsets, then four tables. VARINTS ARE BACKWARDS from every other format in this tree: seven bits per byte, low bits first, and the byte with its high bit SET is the LAST one rather than a continuation. """ import struct, sys class R: def __init__(s, d, o=0): s.d, s.o = d, o def u32(s): v = struct.unpack_from(" 2 else None for i, (c, kv) in enumerate(objs): if want and want not in c: continue print("#%d %s" % (i, c)) for k, v in kv: print(" %-28s %r" % (k, v))