Created
May 19, 2017 14:08
-
-
Save tilacog/adb9756a625abf899a65d73bcd30a0dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import sys | |
def pprint_specfile(path, filters): | |
record_fmt = '{r[name]}: {r[label]}' | |
field_fmt = ' {f[order]}-{f[name]}' | |
with open(path) as fh: | |
data = json.load(fh) | |
for record in data: | |
if filters and record['name'] not in filters: | |
continue | |
print(record_fmt.format(r=record)) | |
for field in record['fields']: | |
print(field_fmt.format(f=field)) | |
if __name__ == '__main__': | |
path, *filters = sys.argv[1:] | |
pprint_specfile(path, filters) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment