#!/usr/bin/env python3 """ Test PS3 Story DLC Application with Borderlands 2 This game has 4 large story DLC packs in NoPayStation. """ import sys from pathlib import Path import shutil # Add ROM Groomer to path sys.path.insert(0, str(Path(__file__).parent.parent / 'rom-groomer-python' / 'src')) from romgroomer.stages.apply_ps3_updates import ApplyPS3UpdatesStage from romgroomer.stages.base import StageContext def main(): """Test DLC application.""" # Paths source_game = Path("/data/emu/ps3netsrv/GAMES/Borderlands 2 (USA) (En,Fr,De,Es,It).ps3") test_game = Path("/tmp/Borderlands 2 (USA) (Test - No DLC).ps3") nps_database = "/data/emu/source/nopaystation/PS3_DLCS.tsv" pkg_archive = "/data/emu/source/nopaystation/downloads-ps3-dlc" pkg2zip_path = "/data/emu/rom-groomer-python/tools/bin/pkg2zip" print("=" * 70) print("Borderlands 2 Story DLC Test") print("=" * 70) print() # Check source if not source_game.exists(): print(f"Error: Source game not found: {source_game}") return 1 # Remove old test if exists if test_game.exists(): print(f"Removing old test copy...") shutil.rmtree(test_game) # Create test copy print("Creating test copy (this will take a minute)...") print(f" Source: {source_game.name}") print(f" Test: {test_game.name}") shutil.copytree(source_game, test_game) print(" ✓ Copied") print() # Show BEFORE state print("=" * 70) print("BEFORE: Test Game State") print("=" * 70) for item in sorted(test_game.iterdir()): if item.is_file(): size = item.stat().st_size print(f" {item.name} ({size:,} bytes)") elif item.is_dir(): count = sum(1 for _ in item.rglob('*')) size = sum(f.stat().st_size for f in item.rglob('*') if f.is_file()) print(f" {item.name}/ ({count} items, {size:,} bytes)") print() # Run DLC stage print("=" * 70) print("Running ApplyPS3UpdatesStage (DLC mode)...") print("=" * 70) stage = ApplyPS3UpdatesStage( nps_database=nps_database, pkg_archive=pkg_archive, pkg2zip_path=pkg2zip_path, apply_updates=False, # No updates available apply_dlc=True # Apply story DLC ) context = StageContext( platform_name="ps3", platform_config={}, target_name="test", source_dir=Path("/tmp"), work_dir=Path("/tmp"), output_dir=Path("/tmp/output") ) result = stage.execute(context) print() # Show AFTER state print("=" * 70) print("AFTER: Test Game State") print("=" * 70) for item in sorted(test_game.iterdir()): if item.is_file(): size = item.stat().st_size print(f" {item.name} ({size:,} bytes)") elif item.is_dir(): count = sum(1 for _ in item.rglob('*')) size = sum(f.stat().st_size for f in item.rglob('*') if f.is_file()) print(f" {item.name}/ ({count} items, {size:,} bytes)") print() print("=" * 70) print("Test Complete!") print("=" * 70) print() return 0 if __name__ == '__main__': sys.exit(main())