69 text = str(fid).zfill(8)
72 group, area, section, number = int(text[0]), text[1:4], int(text[4]), int(text[5:8])
73 if group
not in groups
or area
not in areas:
79 + (number - number % 32) // 8
81 return off, 0x80000000 >> (number % 32)
103 table, seen, undecodable = {}, set(), 0
104 with open(SRC, encoding=
"utf-8")
as f:
105 for r
in csv.DictReader(f):
107 if not fid.isdigit():
109 addr =
address(int(fid), groups, areas)
115 key = (r[
"family"], addr)
119 title = TITLE.get(r[
"family"], r[
"family"].replace(
"_",
" ").title())
120 table.setdefault(title, []).append([addr[0], addr[1], r[
"name"]])
122 sys.exit(
"no rows survived -- check the source CSV")
123 for rows
in table.values():
125 with open(OUT,
"w", encoding=
"utf-8")
as f:
126 json.dump(dict(sorted(table.items())), f, ensure_ascii=
False, indent=1)
128 total = sum(len(v)
for v
in table.values())
130 f
"wrote {OUT}: {total} flags in {len(table)} families ({undecodable} undecodable)"