diff options
author | Ruben Rodriguez <ruben@trisquel.info> | 2015-07-17 14:01:19 -0500 |
---|---|---|
committer | Ruben Rodriguez <ruben@trisquel.info> | 2015-07-17 14:01:19 -0500 |
commit | 52273ee42871b6715f93a5dfe1f200bfa1bbbdbb (patch) | |
tree | 8fcabc489efe226b9bf6dcf157717416d06e0dea | |
parent | dde0f06e1357f302a681225045e3e52c450c0cba (diff) |
Export individual json files
-rw-r--r-- | export_json.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/export_json.py b/export_json.py index a24d00f..e4f0d3d 100644 --- a/export_json.py +++ b/export_json.py @@ -5,6 +5,16 @@ import json import sys import export +import re + +def filename(s, extension): + s_ = re.sub('[^A-Za-z0-9_+.-]', '_', s) + assert s_, s + return s_ + '.' +extension + +def output(path, xs): + with open(path, 'w') as f: + f.write(xs) def main(): data = export.PkgData() @@ -24,9 +34,12 @@ def main(): values = dict(template.values) page.append((tname, values)) - everything[name] = page - - json.dump(everything, sys.stdout, indent=2) + if page != []: + #name=page[0][1]['Name'] + print name + fn=filename(name, 'json') + data = json.dumps(page, sort_keys=True, indent=4, separators=(',', ': ')) + output('output/'+fn, data) if __name__ == '__main__': main() |