---
type: "Source File"
title: "!/usr/bin/env python3"
description: "#!/usr/bin/env python3 \"\"\"Score all EU countries, laws, and institutions using MiniMax.\"\"\" import sys import os import time import json sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from dotenv import."
resource: "https://eu.copecheck.com"
tags: ["copecheck", "eu", "source-file", "py"]
timestamp: "2026-04-29T21:45:06Z"
site: "eu"
source_path: "copecheck-eu/score_all.py"
---

# !/usr/bin/env python3

Source path: `copecheck-eu/score_all.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-04-29T21:45:06Z`

```py
#!/usr/bin/env python3
"""Score all EU countries, laws, and institutions using MiniMax."""
import sys
import os
import time
import json

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from dotenv import load_dotenv
load_dotenv(os.path.join(os.path.dirname(os.path.abspath(__file__)), '.env'))

import db
import scorer

def score_countries():
    print("\n=== SCORING 27 EU MEMBER STATES ===\n")
    countries = db.get_all_countries()
    for i, c in enumerate(countries, 1):
        print(f"[{i}/{len(countries)}] Scoring {c['flag']} {c['name']}...")
        result = scorer.score_country(c)
        if result:
            db.update_country_scores(c['id'], result)
            print(f"  Cope: {result.get('overall_score', 0):.0f} | Screwed: {result.get('screwed_score', 0):.0f} | Demo: {result.get('demographic_score', 0):.0f}")
            print(f"  {result.get('description', '')[:100]}")
        else:
            print(f"  FAILED - no result")
        time.sleep(1)  # Rate limiting

def score_laws():
    print("\n=== SCORING EU LAWS ===\n")
    laws = db.get_all_laws()
    for i, law in enumerate(laws, 1):
        print(f"[{i}/{len(laws)}] Scoring: {law['title'][:60]}...")
        result = scorer.score_law(law)
        if result:
            db.update_law_scores(law['id'], result)
            print(f"  Cope: {result.get('overall_cope_score', 0):.0f} | UnitCost: {result.get('unit_cost_score', 0):.0f} | Prisoner: {result.get('prisoner_dilemma_score', 0):.0f} | Sorites: {result.get('sorites_score', 0):.0f}")
            print(f"  Verdict: {result.get('verdict', 'N/A')}")
        else:
            print(f"  FAILED")
        time.sleep(1)

def score_institutions():
    print("\n=== SCORING EU INSTITUTIONS ===\n")
    institutions = db.get_all_institutions()
    for i, inst in enumerate(institutions, 1):
        print(f"[{i}/{len(institutions)}] Scoring: {inst['name']}...")
        result = scorer.score_institution(inst)
        if result:
            db.upsert_institution({
                'name': inst['name'],
                'cope_score': result.get('cope_score', 0),
                'cope_quotes': json.dumps(result.get('cope_quotes', [])),
                'cope_analysis': result.get('cope_analysis', ''),
                'ai_model': result.get('ai_model', ''),
                'scored_at': 'now'
            })
            print(f"  Cope: {result.get('cope_score', 0):.0f}")
        else:
            print(f"  FAILED")
        time.sleep(1)

def print_leaderboard():
    print("\n" + "=" * 60)
    print("EU COPE LEADERBOARD — RANKED BY SCREWED SCORE")
    print("=" * 60)
    countries = db.get_all_countries(order_by="screwed_score DESC")
    print(f"\n{'#':>3} {'Country':<20} {'Cope':>5} {'Screwed':>8} {'Demo':>5} {'Leader':>7} {'Prep':>5} {'Exp':>4}")
    print("-" * 60)
    for i, c in enumerate(countries, 1):
        print(f"{i:>3} {c['flag']} {c['name']:<17} {c['overall_score']:>5.0f} {c['screwed_score']:>8.0f} {c['demographic_score']:>5.0f} {c['leader_cope_score']:>7.0f} {c['preparedness_score']:>5.0f} {c['exposure_score']:>4.0f}")

    print("\n" + "=" * 60)
    print("EU LAW COPE INDEX")
    print("=" * 60)
    laws = db.get_all_laws()
    for i, l in enumerate(laws, 1):
        print(f"{i:>3}. [{l['overall_cope_score']:>3.0f}] {l['title'][:55]} ({l.get('verdict', 'N/A')})")

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("--countries", action="store_true", help="Score countries only")
    parser.add_argument("--laws", action="store_true", help="Score laws only")
    parser.add_argument("--institutions", action="store_true", help="Score institutions only")
    parser.add_argument("--all", action="store_true", help="Score everything")
    parser.add_argument("--leaderboard", action="store_true", help="Print leaderboard only")
    args = parser.parse_args()

    if args.leaderboard:
        print_leaderboard()
    elif args.countries or args.all:
        score_countries()
        if args.all:
            score_laws()
            score_institutions()
        print_leaderboard()
    elif args.laws:
        score_laws()
        print_leaderboard()
    elif args.institutions:
        score_institutions()
    else:
        # Default: score everything
        score_countries()
        score_laws()
        score_institutions()
        print_leaderboard()
```
