BetterLeaks / scan (push) Successful in 57s
Document 2026-03-28 live-run findings (sync gates, TransitionScene folding, wildcard collision handling, DAV behavior, canonical runhex form) in SKILL docs. Harden finalize/preflight to normalize legacy single-underscore runhex names, support stage-root reruns, and match single-stage files with scene-tag/legacy suffix variations so valid Magnus/Torsten-style assets are packaged automatically.
128 lines
4.5 KiB
Python
128 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Preflight check for a courtesan tier before packaging.
|
|
|
|
Usage:
|
|
python3 preflight_tier.py --tier Comfortable
|
|
"""
|
|
import argparse
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from finalize_courtesan_tier import normalize_provisional_markers
|
|
|
|
BASE_DIR = Path("/home/rick/output/to-dnd-session/Grok-NPCs/Courtesans")
|
|
|
|
# Stages that should be finalized (letters stripped, one keeper per scene)
|
|
FINALIZED_STAGES = ["Dressed", "Teasing", "Teasing More", "Arrival"]
|
|
|
|
|
|
def preflight_check(tier_dir: Path):
|
|
"""Run preflight checks on finalized stages only."""
|
|
issues = []
|
|
warnings = []
|
|
|
|
# Re-run packaging support: if cleanup already happened, inputs live under Stages and Raw Files.
|
|
stage_root = tier_dir / "Stages and Raw Files" if (tier_dir / "Stages and Raw Files").exists() else tier_dir
|
|
if stage_root != tier_dir:
|
|
print(f"INFO: using stage root {stage_root}")
|
|
|
|
# Check 1: No stage letters remaining in finalized stages
|
|
for stage in FINALIZED_STAGES:
|
|
stage_dir = stage_root / stage
|
|
if not stage_dir.exists():
|
|
warnings.append(f"WARN: {stage} folder missing")
|
|
continue
|
|
|
|
for f in stage_dir.glob("*__*.jpg"):
|
|
# Check for stage letter patterns (but not Arrival which uses A1-C6 numbering)
|
|
if stage == "Arrival":
|
|
continue # Arrival uses letter+number, not just letter
|
|
|
|
# Pattern: _StageName + single letter + __
|
|
if re.search(r"_(Dressed|Teasing|TeasingMore)[A-Z]__", f.name):
|
|
issues.append(f"FAIL: Stage letter not stripped: {stage}/{f.name}")
|
|
|
|
# Check 2: Normalize provisional markers in multi-variant stages.
|
|
# Supports markers like (3b), (3c), (last-2), (last-1), (last), etc.
|
|
for stage in ["Topless", "Topless Plus", "Undressed"]:
|
|
stage_dir = stage_root / stage
|
|
if not stage_dir.exists():
|
|
continue
|
|
try:
|
|
changes = normalize_provisional_markers(stage_dir)
|
|
if changes:
|
|
print(f"INFO: normalized {len(changes)} provisional marker(s) in {stage}")
|
|
except Exception as e:
|
|
issues.append(f"FAIL: {stage} marker normalization: {e}")
|
|
|
|
# Check 3: Count finalized stage files
|
|
for stage in FINALIZED_STAGES:
|
|
stage_dir = stage_root / stage
|
|
if stage_dir.exists():
|
|
count = len(list(stage_dir.glob("*__*.jpg")))
|
|
print(f"INFO: {count} {stage} files")
|
|
|
|
# Check 4: ArrivalAll composites
|
|
arrival_dir = stage_root / "Arrival"
|
|
if arrival_dir.exists():
|
|
arrival_all_singles = list(arrival_dir.glob("ArrivalAllSingles_*.jpg"))
|
|
arrival_all_men = list(arrival_dir.glob("ArrivalAllMen_*.jpg"))
|
|
arrival_all_ladies = list(arrival_dir.glob("ArrivalAllLadies_*.jpg"))
|
|
|
|
if not arrival_all_singles:
|
|
warnings.append("WARN: No ArrivalAllSingles composites found")
|
|
else:
|
|
print(f"INFO: {len(arrival_all_singles)} ArrivalAllSingles composites")
|
|
|
|
if arrival_all_men:
|
|
print(f"INFO: {len(arrival_all_men)} ArrivalAllMen composites")
|
|
if arrival_all_ladies:
|
|
print(f"INFO: {len(arrival_all_ladies)} ArrivalAllLadies composites")
|
|
|
|
return issues, warnings
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser(description="Preflight check for courtesan tier")
|
|
ap.add_argument('--tier', required=True, help='Tier name (e.g., Modest, Comfortable)')
|
|
ap.add_argument('--base-dir', default=str(BASE_DIR), help='Base directory for tiers')
|
|
args = ap.parse_args()
|
|
|
|
tier_dir = Path(args.base_dir) / args.tier
|
|
if not tier_dir.exists():
|
|
print(f"ERROR: Tier directory not found: {tier_dir}")
|
|
return 1
|
|
|
|
print("=" * 60)
|
|
print(f"{args.tier.upper()} TIER PREFLIGHT")
|
|
print("=" * 60)
|
|
|
|
print("\nRunning preflight checks (finalized stages only)...")
|
|
issues, warnings = preflight_check(tier_dir)
|
|
|
|
if warnings:
|
|
print("\nWARNINGS:")
|
|
for w in warnings:
|
|
print(f" {w}")
|
|
|
|
if issues:
|
|
print("\n" + "=" * 60)
|
|
print("PREFLIGHT FAILED")
|
|
print("=" * 60)
|
|
for issue in issues:
|
|
print(f" {issue}")
|
|
print("\nFix issues before packaging.")
|
|
return 1
|
|
else:
|
|
print("\n" + "=" * 60)
|
|
print("PREFLIGHT PASSED ✓")
|
|
print("=" * 60)
|
|
print(f"\n{args.tier} tier ready for finalization and packaging.")
|
|
print("\nNote: Topless not checked (human review not yet complete).")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|