aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--export_json.py19
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()