diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:44:55 +0000 |
commit | 5068d34c08f951a7ea6257d305a1627b09a95817 (patch) | |
tree | 08213e2be853396a3b07ce15dbe222644dcd9a89 /src/format2csv.py | |
parent | Initial commit. (diff) | |
download | lnav-5068d34c08f951a7ea6257d305a1627b09a95817.tar.xz lnav-5068d34c08f951a7ea6257d305a1627b09a95817.zip |
Adding upstream version 0.11.1.upstream/0.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/format2csv.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/format2csv.py b/src/format2csv.py new file mode 100644 index 0000000..a4d4d6d --- /dev/null +++ b/src/format2csv.py @@ -0,0 +1,23 @@ + +import glob +import csv +import sys +import json + +def main(args): + with open(args[1], 'w') as ofp: + out = csv.writer(ofp) + for format_path in sorted(glob.glob("%s/*.json" % args[2])): + with open(format_path) as fp: + format_dict = json.load(fp) + + for key in sorted(format_dict): + value = format_dict[key] + if not isinstance(value, dict): + continue + if 'title' not in value: + raise Exception("format '%s' is missing 'title'" % key) + out.writerow((value['title'], key, value['description'])) + +if __name__ == "__main__": + sys.exit(main(sys.argv)) |