Mon, 28 Jan 2019 21:51:45 +0100
Add the (missing?) Keypad lib
23 | 1 | import zipfile |
2 | import configparser | |
3 | ||
4 | ||
5 | def extract_metadata(fname): | |
6 | cfg = configparser.ConfigParser() | |
7 | with zipfile.ZipFile(fname) as zf: | |
8 | mdata = zf.open('metadata').read() | |
9 | cfg.read_string(mdata.decode()) | |
10 | return cfg | |
11 | ||
12 | ||
13 | def print_metadata(mdata): | |
14 | for kv in mdata['global'].items(): | |
15 | print('%s: %s' % kv) | |
16 | for device, cfg in mdata.items(): | |
17 | if device in ('global', 'DEFAULT'): | |
18 | continue | |
19 | print('%s:' % device) | |
20 | for kv in cfg.items(): | |
21 | print(' %s: %s' % kv) | |
22 | ||
23 | ||
24 | if __name__ == '__main__': | |
25 | import sys | |
26 | for fn in sys.argv[1:]: | |
27 | print_metadata(extract_metadata(fn)) |