Update updater workflows, remove countries outside ISO-3366-2, cleanup

This commit is contained in:
Alexandre Gomes Gaigalas 2023-02-15 00:29:10 -03:00
parent 1e2f75287c
commit 74dee73f65
7 changed files with 9 additions and 42 deletions

View file

@ -1,6 +1,7 @@
name: Update currency codes
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

View file

@ -1,6 +1,7 @@
name: Update language codes
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

View file

@ -1,8 +1,9 @@
name: Update top-level domains
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
- cron: '0 0 * * *'
jobs:
update-tld:

View file

@ -11,9 +11,9 @@ declare -r LIBRARY_DIRECTORY="library"
clone_repository()
{
echo "Cloning repository ${REPOSITORY_URL}"
if ! test -d "$REPOSITORY_DIRECTORY"
then
echo "Cloning repository ${REPOSITORY_URL}"
git clone --quiet "${REPOSITORY_URL}" "${REPOSITORY_DIRECTORY}"
fi
}
@ -65,6 +65,10 @@ update_subdivision_codes()
local last_country_code=""
local last_country_rule=""
rm -rf data/iso_3166-2/*
echo "Updating subdivision codes using ISO 3166-2"
for index in $(seq 0 $[iso_3166_1_count - 1]); do
local json=$(jq ".[][${index}]" < "${iso_3166_1_filename}")
local alpha_1="$(jq ".alpha_2" <<< "${json}" | tr -d '"')"
@ -89,26 +93,6 @@ update_subdivision_codes()
echo " }
}" >> "data/iso_3166-2/${alpha_1}.json"
done
return
echo "Updating subdivision codes using ISO 3166-2"
for index in $(seq 0 $[iso_3166_2_count - 1]); do
local json=$(jq ".[][${index}]" < "${iso_3166_2_filename}")
local code=$(jq -r ".code" <<< "${json}")
local name=$(jq -r ".name" <<< "${json}")
local current_country_code=$(cut --delimiter "-" --fields 1 <<< "${code}")
if [[ ${last_country_code} != ${current_country_code} ]]; then
echo "- Updating ${current_country_code}"
fi
last_country_code=${current_country_code}
done
}
clone_repository

View file

@ -1,5 +0,0 @@
{
"source": "http://www.geonames.org/AN/administrative-division-netherlands-antilles.html",
"country": "Netherlands Antilles",
"subdivisions": []
}

View file

@ -1,10 +0,0 @@
{
"source": "http://www.geonames.org/CS/administrative-division-serbia-and-montenegro.html",
"country": "Serbia And Montenegro",
"subdivisions": {
"KOS": "Kosovo",
"MON": "Montenegro",
"SER": "Serbia",
"VOJ": "Vojvodina"
}
}

View file

@ -1,5 +0,0 @@
{
"source": "http://www.geonames.org/XK/administrative-division-kosovo.html",
"country": "Kosovo",
"subdivisions": []
}