diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-16 15:17:31 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2014-04-16 15:17:31 -0400 |
commit | e417662dce5cae2e95ef98ee38baa8f53a02b9d5 (patch) | |
tree | dce94fb8524dece7e3fcc677ec0cf908a6ec2a97 /ast2json/settings2json.py | |
parent | 6a50d79523cf215001cdd55c74c040bd410775df (diff) | |
download | html5ks-e417662dce5cae2e95ef98ee38baa8f53a02b9d5.tar.xz html5ks-e417662dce5cae2e95ef98ee38baa8f53a02b9d5.zip |
mbleh
Diffstat (limited to 'ast2json/settings2json.py')
-rwxr-xr-x | ast2json/settings2json.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ast2json/settings2json.py b/ast2json/settings2json.py new file mode 100755 index 0000000..a72239d --- /dev/null +++ b/ast2json/settings2json.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import json +import sys + +def settings2json(ast): + ret = {} + if ast[0]['_type'] != 'Label': + raise TypeError('obj does not start with Label, wrong file?') + for label in ast: + if label['parameters'] is not None: + raise NotImplementedError() + ret[label['name']] = label['block'] + return ret + +with open(sys.argv[1], 'r') as f: + output = settings2json(json.load(f)) + +json.dump(output, open(sys.argv[2], 'w'), separators=(',', ':')) |