refactor(clew): flatten Ren'Py AST extraction
This commit is contained in:
@@ -104,18 +104,22 @@ def ast_dump_output_path(output_root: Path, extracted_root: Path, game_root: Pat
|
|||||||
return output_root / "ast" / namespace / relative_script.with_suffix(relative_script.suffix + ".json")
|
return output_root / "ast" / namespace / relative_script.with_suffix(relative_script.suffix + ".json")
|
||||||
|
|
||||||
|
|
||||||
def run_extract_renpy_ast(game_root: Path, script: Path, output: Path) -> None:
|
def run_extract_renpy_ast(
|
||||||
exporter = Path(dump_ast_script.__file__).resolve()
|
bundled_python: Path,
|
||||||
bundled_python = game_root / "lib" / "linux-x86_64" / "python"
|
extractor: Path,
|
||||||
|
game_root: Path,
|
||||||
|
compiled_script: Path,
|
||||||
|
output: Path,
|
||||||
|
) -> None:
|
||||||
output.parent.mkdir(parents=True, exist_ok=True)
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
command = [
|
command = [
|
||||||
"steam-run",
|
"steam-run",
|
||||||
str(bundled_python),
|
str(bundled_python),
|
||||||
str(exporter),
|
str(extractor),
|
||||||
"--game-root",
|
"--game-root",
|
||||||
str(game_root),
|
str(game_root),
|
||||||
"--input",
|
"--input",
|
||||||
str(script),
|
str(compiled_script),
|
||||||
"--output",
|
"--output",
|
||||||
str(output),
|
str(output),
|
||||||
]
|
]
|
||||||
@@ -123,6 +127,7 @@ def run_extract_renpy_ast(game_root: Path, script: Path, output: Path) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def extract_game_ast(output_root: Path, extracted_root: Path, overwrite: bool) -> None:
|
def extract_game_ast(output_root: Path, extracted_root: Path, overwrite: bool) -> None:
|
||||||
|
extractor = Path(dump_ast_script.__file__).resolve()
|
||||||
game_roots = find(
|
game_roots = find(
|
||||||
extracted_root,
|
extracted_root,
|
||||||
lambda path: (
|
lambda path: (
|
||||||
@@ -136,6 +141,7 @@ def extract_game_ast(output_root: Path, extracted_root: Path, overwrite: bool) -
|
|||||||
return
|
return
|
||||||
|
|
||||||
for game_root in game_roots:
|
for game_root in game_roots:
|
||||||
|
bundled_python = game_root / "lib" / "linux-x86_64" / "python"
|
||||||
scripts = find(
|
scripts = find(
|
||||||
game_root / "game",
|
game_root / "game",
|
||||||
lambda path: path.is_file() and path.suffix.lower() in {".rpyc", ".rpymc"},
|
lambda path: path.is_file() and path.suffix.lower() in {".rpyc", ".rpymc"},
|
||||||
@@ -147,7 +153,7 @@ def extract_game_ast(output_root: Path, extracted_root: Path, overwrite: bool) -
|
|||||||
LOG.info("skipping existing AST dump: %s", output)
|
LOG.info("skipping existing AST dump: %s", output)
|
||||||
continue
|
continue
|
||||||
LOG.info("dumping AST: %s", script)
|
LOG.info("dumping AST: %s", script)
|
||||||
run_extract_renpy_ast(game_root, script, output)
|
run_extract_renpy_ast(bundled_python, extractor, game_root, script, output)
|
||||||
|
|
||||||
|
|
||||||
def run(args: argparse.Namespace) -> None:
|
def run(args: argparse.Namespace) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user