diff options
Diffstat (limited to 'ast2json')
-rwxr-xr-x | ast2json/rpyc2json.py | 2 | ||||
-rwxr-xr-x | ast2json/script2json.py | 2 | ||||
-rwxr-xr-x | ast2json/settings2json.py | 19 |
3 files changed, 22 insertions, 1 deletions
diff --git a/ast2json/rpyc2json.py b/ast2json/rpyc2json.py index b1dc592..7c8518b 100755 --- a/ast2json/rpyc2json.py +++ b/ast2json/rpyc2json.py @@ -79,6 +79,8 @@ def get_value(attr_value): } if isinstance(attr_value, renpy.ast.ArgumentInfo): return list(map(lambda x: getattr(attr_value, x), ["arguments", "extrapos", "extrakw"])) + if isinstance(attr_value, renpy.ast.ParameterInfo): + return dict((name, getattr(attr_value, name)) for name in dir(attr_value) if not name.startswith('__')) if isinstance(attr_value, renpy.atl.RawBlock): return 'ATL not implemented' diff --git a/ast2json/script2json.py b/ast2json/script2json.py index 60be575..d5cafa2 100755 --- a/ast2json/script2json.py +++ b/ast2json/script2json.py @@ -44,7 +44,7 @@ def print_Return(stmt): return [stmt['expression']] def print_UserStatement(stmt): - return [stmt['line']] + return [stmt['line'], stmt['parsed']] def print_Init(stmt): raise NotImplementedError() 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=(',', ':')) |