From de844dacb31531781e9f97ec25a52ea246f1115b Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Sun, 18 Aug 2013 21:55:02 -0400 Subject: prep for i18n --- unrpyc/Makefile | 4 ++-- unrpyc/decompiler.py | 40 ++++++++++++++++++---------------- www/index.html | 61 ++++++++++++++++++++++++++-------------------------- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/unrpyc/Makefile b/unrpyc/Makefile index ea97e56..b64bb22 100644 --- a/unrpyc/Makefile +++ b/unrpyc/Makefile @@ -1,6 +1,6 @@ gzip := $(shell ./find-gzip.sh) -all: script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz +all: script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz ui-strings.json ui-strings.json.gz %.json.gz: %.json $(gzip) -c $< > $@ @@ -27,7 +27,7 @@ test: all jshint --show-non-errors *.json install: all - install -t ../www/scripts script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz + install -t ../www/scripts script.json script.json.gz imachine.json imachine.json.gz imachine_replay.json imachine_replay.json.gz ui-strings.json ui-strings.json.gz uninstall: rm -f ../www/scripts/* diff --git a/unrpyc/decompiler.py b/unrpyc/decompiler.py index 75aced6..38fbd52 100644 --- a/unrpyc/decompiler.py +++ b/unrpyc/decompiler.py @@ -273,6 +273,13 @@ class PrintRenPython(python_ast.NodeVisitor): def visit_Attribute(self, node): return '"%s"' % node.attr + def visit_Assign(self, node): + if not isinstance(node.targets[0], python_ast.Subscript): + self.f.write(self.visit(node.targets[0])) + self.f.write(': ') + self.f.write(self.visit(node.value)) + self.f.write(',\n') + def visit_Call(self, node): self.f.write('[') self.f.write(self.visit(node.func)) @@ -295,6 +302,16 @@ class PrintRenPython(python_ast.NodeVisitor): def visit_Dict(self, node): return self.quote(python_ast.dump(node)) + def visit_List(self, node): + ret = '[' + delim = '' + for elt in node.elts: + ret += delim + ret += self.visit(elt) + delim = ',' + ret += ']' + return ret + def visit_Num(self, node): return json.dumps(node.n) @@ -304,6 +321,9 @@ class PrintRenPython(python_ast.NodeVisitor): def visit_Str(self, node): return json.dumps(node.s) + def visit_Tuple(self, node): + return self.visit_List(node) + def visit_keyword(self, node): return self.visit(node.value) @@ -312,20 +332,8 @@ def print_Python(f, stmt, indent_level, early=False): stripped_code = code_src.strip() - if stripped_code.count('\n') == 0: - stmt = compile(code_src, '', 'exec', python_ast.PyCF_ONLY_AST).body[0] - PrintRenPython(f).visit(stmt) - else: - f.write("python") - if early: - f.write(" early") - if stmt.hide: - f.write(" hide") - f.write(":\n") - - for line in code_src.splitlines(True): - indent(f, indent_level + 1) - f.write(line) + stmt = compile(code_src, '', 'exec', python_ast.PyCF_ONLY_AST) + PrintRenPython(f).visit(stmt) def print_Return(f, stmt, indent_level): if stmt.expression is not None: @@ -337,10 +345,6 @@ def print_UserStatement(f, stmt, indent_level): f.write('["%s"],\n' % (escape_string(stmt.line).replace(' ', '", "'), )) def print_Init(f, stmt, indent_level): - f.write("init") - if stmt.priority != 0: - f.write(" %d" % (stmt.priority, )) - f.write(":\n") for s in stmt.block: print_statement(f, s, indent_level + 1) diff --git a/www/index.html b/www/index.html index 4c4f7fb..6a44ab4 100644 --- a/www/index.html +++ b/www/index.html @@ -37,7 +37,8 @@
  • It doesn't seem to support the @font-face at-rule, which lets us display the Playtime and Gentium fonts used in Katawa Shoujo. Any browser released in the last 2 years or so should support it.
  • It doesn't seem to support CSS transforms, which means that we won't be able to scale the window or show most transitions. Any browser released in the last 2 years ago should work.
  • It doesn't seem to support CSS transitions, which means that almost all animations won't work. Videos should still work though, unless stated above. You should definitely consider upgrading.
  • -
    I know it's broken, let me play!
    + +
    I know it's broken, let me play!
    @@ -58,11 +59,11 @@