0
0
mirror of https://github.com/lipis/flag-icons.git synced 2024-11-21 18:38:57 +01:00

Flag codes

This commit is contained in:
Panayiotis Lipiridis 2021-10-23 12:15:03 +03:00
parent 5157abf930
commit 3fd30007c4
3 changed files with 300 additions and 44 deletions

View File

@ -27,9 +27,7 @@ window.onload = function () {
// Code
const codeSpan = document.createElement('span');
codeSpan.classList.add('flag-code');
const code = document.createTextNode(
country.flag_4x3.substr(10).replace('.svg', ''),
);
const code = document.createTextNode(country.code);
codeSpan.appendChild(code);
//Country

File diff suppressed because it is too large Load Diff

View File

@ -3,33 +3,33 @@ import json
flags_dir = os.path.join("flags", "1x1")
f = []
files = []
for (dirpath, dirnames, filenames) in os.walk(flags_dir):
f.extend(filenames)
files.extend(filenames)
break
codes = [name.replace('.svg', '') for name in f]
file_codes = [name.replace('.svg', '') for name in files]
country_json = open("country.json")
flags = json.load(country_json)
flags.sort(key=lambda x: x["flag_1x1"])
flags.sort(key=lambda x: x["code"])
with open('country.json', 'w') as output:
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]
country_codes = [flag["code"] for flag in flags]
all_good = True
for code in codes:
if code not in countries:
for code in file_codes:
if code not in country_codes:
print('Code not found in country.json:', code)
all_good = False
for code in countries:
if code not in codes:
# Check if all countries have files
for code in country_codes:
if code not in file_codes:
print('Flag icon not found for:', code)
all_good = False