# /// script # dependencies = ["pycountry"] # /// """Writes src/countries.rs: ISO 3166-1 alpha-3 codes with English short names. uv run scripts/gen_countries.py > src/countries_data.rs The names come from pycountry (Debian's iso-codes); `common_name` wins where iso-codes has one ("Bolivia" instead of "Bolivia, Plurinational State of"). """ import json import pycountry rows = sorted( (c.alpha_3, getattr(c, "common_name", None) or c.name) for c in pycountry.countries ) print("// Generated by scripts/gen_countries.py from pycountry; do not edit by hand.") print("pub static COUNTRIES: &[(&str, &str)] = &[") for code, name in rows: print(f" ({json.dumps(code)}, {json.dumps(name, ensure_ascii=False)}),") print("];")