0
0
mirror of https://github.com/lipis/flag-icons.git synced 2024-11-24 19:36:55 +01:00
flags/flags.py

39 lines
850 B
Python
Raw Normal View History

2021-10-22 22:26:29 +02:00
import os
import json
2021-10-23 10:43:06 +02:00
flags_dir = os.path.join("flags", "1x1")
2021-10-22 22:26:29 +02:00
f = []
for (dirpath, dirnames, filenames) in os.walk(flags_dir):
f.extend(filenames)
break
codes = [name.replace('.svg', '') for name in f]
country_json = open("country.json")
flags = json.load(country_json)
flags.sort(key=lambda x: x["flag_1x1"])
with open('country.json', 'w') as output:
2021-10-23 10:43:06 +02:00
json.dump(flags, output, indent=2, sort_keys=True)
# Check if all files have names
countries = [flag["flag_1x1"][10:].replace('.svg', '') for flag in flags]
all_good = True
for code in codes:
if code not in countries:
print('Code not found in country.json:', code)
all_good = False
for code in countries:
if code not in codes:
print('Flag icon not found for:', code)
all_good = False
if all_good:
print('All flag icons and country.json are in sync.')