12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import argparse
- import sys
- import subprocess
- from pathlib import Path
- def run_subprocess(script_name, input_dir, output_dir, indent=None):
- """Helper function to run a parser subprocess."""
- script_path = Path(__file__).parent / "parsers" / script_name
- command = [
- sys.executable,
- str(script_path),
- "--input",
- str(input_dir),
- "--output",
- str(output_dir)
- ]
- if indent is not None:
- command.extend(["--indent", str(indent)])
-
- try:
- subprocess.run(command, check=True, text=True, capture_output=True)
- except subprocess.CalledProcessError as e:
- print(f"--- ERROR in {script_name} ---")
- print(e.stdout)
- print(e.stderr)
- print(f"--- End of Error ---")
- def main():
- """
- Main function to orchestrate the low-level data extraction pipeline.
- """
- parser = argparse.ArgumentParser(
- description="Orchestrates a pipeline of parsers for a detailed data breakdown."
- )
- parser.add_argument("--input", type=str, required=True, help="The root directory of the target Unity project.")
- parser.add_argument("--output", type=str, required=True, help="The directory where the output folder will be saved.")
- parser.add_argument("--indent", type=int, default=None, help="Indentation level for JSON output.")
- args = parser.parse_args()
- input_dir = Path(args.input).resolve()
- output_dir = Path(args.output).resolve()
- if not input_dir.is_dir():
- print(f"Error: Input path '{input_dir}' is not a valid directory.", file=sys.stderr)
- sys.exit(1)
- low_level_output_dir = output_dir / "LowLevel"
- low_level_output_dir.mkdir(parents=True, exist_ok=True)
- print(f"Output will be saved to: {low_level_output_dir}")
- # --- Run Extraction Pipeline ---
- run_subprocess("copy_scripts.py", input_dir, low_level_output_dir, args.indent)
- run_subprocess("copy_shaders.py", input_dir, low_level_output_dir, args.indent)
- run_subprocess("parse_project_settings.py", input_dir, low_level_output_dir, args.indent)
- run_subprocess("parse_generic_assets.py", input_dir, low_level_output_dir, args.indent)
- run_subprocess("parse_scenes_and_prefabs.py", input_dir, low_level_output_dir, args.indent)
- print("\nLow-level extraction pipeline complete.")
- if __name__ == "__main__":
- main()
|