Skip to content

Commit caf24ad

Browse files
committed
Add Kosovo (XK) entry via generate.py patch
1 parent c899dbe commit caf24ad

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

generate.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@
4848
dst = os.path.join(database_dir, "iso%s.json" % standard)
4949
shutil.copyfile(src, dst)
5050

51+
# --- Manually patch Kosovo into iso3166-1.json ---
52+
import json
53+
54+
filename = os.path.join(database_dir, "iso3166-1.json")
55+
with open(filename, "r", encoding="utf-8") as f:
56+
countries_data = json.load(f)
57+
58+
countries_list = countries_data["3166-1"]
59+
60+
# Avoid duplication if Kosovo already exists
61+
if not any(c.get("alpha_2") == "XK" for c in countries_list):
62+
countries_list.append({
63+
"alpha_2": "XK",
64+
"alpha_3": "XKX",
65+
"numeric": "999",
66+
"name": "Kosovo",
67+
"flag": "🇽🇰"
68+
})
69+
70+
# Write back the full dict with your modified list
71+
with open(filename, "w", encoding="utf-8") as f:
72+
json.dump(countries_data, f, indent=2, ensure_ascii=False)
5173

5274
# Put the PO files in place and compile them
5375
for standard in STANDARDS:

src/pycountry/databases/iso3166-1.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,13 @@
19261926
"name": "Zimbabwe",
19271927
"numeric": "716",
19281928
"official_name": "Republic of Zimbabwe"
1929+
},
1930+
{
1931+
"alpha_2": "XK",
1932+
"alpha_3": "XKX",
1933+
"numeric": "999",
1934+
"name": "Kosovo",
1935+
"flag": "🇽🇰"
19291936
}
19301937
]
1931-
}
1938+
}

0 commit comments

Comments
 (0)