예제 #1
0
파일: compile.py 프로젝트: sldr23876/unrpyc
decompiler = p.ExecTranspile(
    """
# Set up the namespace
from os.path import join
from os import getcwd
from sys import modules, meta_path
from renpy.loader import listdirfiles

# and some things we store in the global namespace so we can access them inside exec
global basepath
global files
global __package__

# an easter egg
exec '''
try:
    import renpy
except Exception:
    raise _Stop(({"version": "broken", "key": "thrown away"}, []))
''' in globals()

basepath = join(getcwd(), "game")
files = listdirfiles()

exec '''
import os, sys, renpy
sys.files = []
for (dir, fn) in files:
    if fn.endswith(".rpyc"):
        if dir and dir.endswith("common"):
            continue
        elif fn == "un.rpyc":
            continue
        elif (dir, fn[:-1]) not in files:
            abspath = os.path.join(dir, fn) if dir else os.path.join(basepath, fn)
            fobj = renpy.loader.load(fn)
            sys.files.append((abspath, fn, dir, fobj))
''' in globals()

_0 # util
_1 # magic
_2 # codegen

renpy_modules = modules.copy()

exec '''
import sys
for i in sys.modules.copy():
    if "renpy" in i and not "renpy.execution" in i:
        sys.modules.pop(i)
''' in globals()

renpy_loader = meta_path.pop()
package = __package__
__package__ = ""

import traceback as traceback
import codecs as codecs

from magic import fake_package, FakeModule, remove_fake_package
# fake the prescense of renpy
fake_package("renpy")
# astdump and translate are unused
FakeModule("astdump")
FakeModule("translate")

_3 # testcasedecompiler
_4 # screendecompiler
_5 # sl2decompiler
_6 # decompiler
_7 # unrpyc

from unrpyc import decompile_game
decompile_game()
remove_fake_package("renpy")

modules.update(renpy_modules)
meta_path.append(renpy_loader)
__package__ = package

from renpy import script_version
from renpy.game import script
({'version': script_version, 'key': script.key}, [])
""", (Module("util", path.join(base_folder, "decompiler/util.py")),
      Module("magic", path.join(base_folder, "decompiler/magic.py"), False),
      Module("codegen", path.join(base_folder, "decompiler/codegen.py")),
      Module("testcasedecompiler",
             path.join(base_folder, "decompiler/testcasedecompiler.py")),
      Module("screendecompiler",
             path.join(base_folder, "decompiler/screendecompiler.py")),
      Module("sl2decompiler",
             path.join(base_folder, "decompiler/sl2decompiler.py")),
      Module("decompiler", path.join(base_folder, "decompiler/__init__.py")),
      Module("unrpyc", path.join(pack_folder, "unrpyc-compile.py"))))
예제 #2
0
from unrpyc import decompile_game
decompile_game()
remove_fake_package("renpy")

modules.update(renpy_modules)
meta_path.append(renpy_loader)
__package__ = package
"""

decompiler_rpyc = p.ExecTranspile(base + """
from renpy import script_version
from renpy.game import script
({'version': script_version, 'key': script.key}, [])
""", (
    Module("util", path.join(base_folder, "decompiler/util.py")),
    Module("magic", path.join(base_folder, "decompiler/magic.py"), False),
    Module("codegen", path.join(base_folder, "decompiler/codegen.py")),
    Module("testcasedecompiler", path.join(base_folder, "decompiler/testcasedecompiler.py")),
    Module("screendecompiler", path.join(base_folder, "decompiler/screendecompiler.py")),
    Module("sl2decompiler", path.join(base_folder, "decompiler/sl2decompiler.py")),
    Module("decompiler", path.join(base_folder, "decompiler/__init__.py")),
    Module("unrpyc", path.join(pack_folder, "unrpyc-compile.py"))
))

decompiler_rpyb = p.ExecTranspile(base + "(None, [])\n", (
    Module("util", path.join(base_folder, "decompiler/util.py")),
    Module("magic", path.join(base_folder, "decompiler/magic.py"), False),
    Module("codegen", path.join(base_folder, "decompiler/codegen.py")),
    Module("testcasedecompiler", path.join(base_folder, "decompiler/testcasedecompiler.py")),
    Module("screendecompiler", path.join(base_folder, "decompiler/screendecompiler.py")),
    Module("sl2decompiler", path.join(base_folder, "decompiler/sl2decompiler.py")),
    Module("decompiler", path.join(base_folder, "decompiler/__init__.py")),