#!/usr/bin/env python3
import os
import xml.etree.ElementTree as ET
import glob

def validate_svg(svg_path):
    """Basic SVG validation checks"""
    try:
        tree = ET.parse(svg_path)
        root = tree.getroot()
        
        # Check for viewBox
        if 'viewBox' not in root.attrib:
            print(f"Warning: No viewBox in {svg_path}")
        
        # Check text elements for readability
        text_elements = root.findall('.//{http://www.w3.org/2000/svg}text')
        if not text_elements:
            print(f"Warning: No text elements in {svg_path}")
        
        for text in text_elements:
            if 'font-size' not in text.attrib or float(text.attrib['font-size']) < 10:
                print(f"Warning: Small text in {svg_path}")
        
        return True
    except Exception as e:
        print(f"Error validating {svg_path}: {e}")
        return False

def generate_batch_report(batch_dir):
    """Generate a report on the SVG batch"""
    svg_files = sorted(glob.glob(os.path.join(batch_dir, '*.svg')))
    report = f"SVG Batch Report ({len(svg_files)} files)\n"
    report += "=" * 40 + "\n\n"
    
    for svg_path in svg_files:
        is_valid = validate_svg(svg_path)
        
        report += f"File: {os.path.basename(svg_path)}\n"
        report += f"Status: {'✅ Valid' if is_valid else '❌ Invalid'}\n\n"
    
    with open(os.path.join(batch_dir, 'batch_review.md'), 'w') as f:
        f.write(report)
    
    print(report)

if __name__ == "__main__":
    import sys
    batch_dir = sys.argv[1] if len(sys.argv) > 1 else '/Users/tonyclaw/.openclaw/workspace/drafts/svg-batch-2/'
    generate_batch_report(batch_dir)
# TONY-APPROVED: 2026-03-01 | sha:7eb8dc4c

# TONY-APPROVED: 2026-03-01 | sha:c7c64cd7
