**Motivations:** - Implémenter le workflow complet de démonstration Collatz (commandes.md) - Permettre la reprise après interruption au palier D20 **Evolutions:** - Scripts 01-12 et run-full-workflow alignés sur commandes.md sections 1-10 - collatz_recover_noyau.py : recréation de noyau_post_D20 à partir du CSV candidats - Option --resume-from D20 dans collatz_k_pipeline pour reprendre sans recalculer D18-D19-F15 - Détection automatique : si candidats_D20 existe sans noyau_post_D20, récupération puis poursuite - Filtres --cible=critique et --modulo dans collatz_fusion_pipeline - ROOT par défaut = collatz_k_scripts (plus data/source vide) **Pages affectées:** - .gitignore (__pycache__, out/) - applications/collatz/collatz_k_scripts/*.py - applications/collatz/scripts/*.sh - applications/collatz/scripts/README.md
98 lines
2.9 KiB
Python
98 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
collatz_generate_readme.py
|
|
|
|
Generate README with usage and file list.
|
|
|
|
Usage: python collatz_generate_readme.py --certificat JSON --audits-dir DIR --output README.md
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
def load_json(path: str) -> dict[str, Any]:
|
|
"""Load JSON file."""
|
|
p = Path(path)
|
|
if not p.exists():
|
|
return {}
|
|
try:
|
|
return json.loads(p.read_text(encoding="utf-8"))
|
|
except json.JSONDecodeError:
|
|
return {}
|
|
|
|
|
|
def get_cert_info(data: dict[str, Any]) -> list[str]:
|
|
"""Extract certificate info for README."""
|
|
lines: list[str] = []
|
|
if "depth" in data:
|
|
lines.append(f"- Depth: {data['depth']}")
|
|
clauses = data.get("closed") or data.get("clauses") or []
|
|
if clauses:
|
|
lines.append(f"- Clauses: {len(clauses)}")
|
|
return lines
|
|
|
|
|
|
def list_audit_files(audits_dir: str) -> list[str]:
|
|
"""List audit files in directory."""
|
|
root = Path(audits_dir)
|
|
if not root.exists():
|
|
return []
|
|
return [p.name for p in sorted(root.iterdir()) if p.is_file()]
|
|
|
|
|
|
def run(cert_path: str, audits_dir: str, output_path: str) -> None:
|
|
"""Generate README."""
|
|
cert_data = load_json(cert_path)
|
|
audit_files = list_audit_files(audits_dir)
|
|
|
|
lines: list[str] = [
|
|
"# Collatz certificate package",
|
|
"",
|
|
"## Usage",
|
|
"",
|
|
"```bash",
|
|
"python collatz_verifier_minimal.py --certificat=certificat.json --output=verif.md",
|
|
"python collatz_verifier_alternative.py --certificat=certificat.json --output=verif_alt.md",
|
|
"python collatz_compare_verifiers.py --verif1=verif.md --verif2=verif_alt.md --output=compare.md",
|
|
"python collatz_generate_progress_log.py --audits-dir=audits --output=journal.md",
|
|
"python collatz_document_base_states.py --base-projective=registre.json --output=states.md",
|
|
"```",
|
|
"",
|
|
"## Certificate",
|
|
"",
|
|
]
|
|
|
|
cert_info = get_cert_info(cert_data)
|
|
if cert_info:
|
|
lines.extend(cert_info)
|
|
else:
|
|
lines.append(f"Certificate: {cert_path}")
|
|
|
|
lines.extend(["", "## Audit files", ""])
|
|
if audit_files:
|
|
for f in audit_files:
|
|
lines.append(f"- {f}")
|
|
else:
|
|
lines.append(f"Audits directory: {audits_dir} (no files)")
|
|
|
|
Path(output_path).write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="Generate README with usage and file list")
|
|
parser.add_argument("--certificat", required=True, help="Path to certificate JSON")
|
|
parser.add_argument("--audits-dir", required=True, help="Path to audits directory")
|
|
parser.add_argument("--output", required=True, help="Path to output README.md")
|
|
args = parser.parse_args()
|
|
run(args.certificat, args.audits_dir, args.output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|