aboutsummaryrefslogtreecommitdiff
path: root/export_json.py
blob: 370b5fee31977209e0572f9d356f483b2739debc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import sys

import export

def main():
    data = export.PkgData()
    everything = {}

    for (name, templates) in export.export_all(data):
        page = []

        try:
            # Force errors.
            templates = list(templates)
        except export.ExportFailure, e:
            export.warn('export failed: %s: %s' % (name, e.message))

        for template in templates:
            tname = template.name
            values = dict(template.values)
            page.append((tname, values))

        everything[name] = page

    json.dump(everything, sys.stdout, indent=2)

if __name__ == '__main__':
    main()