From b0f2e6ea335060a3103b6fa717debf488d75b9cd Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Mon, 11 Mar 2024 10:36:38 +0100 Subject: [PATCH 1/2] Update source of continentmap to original CSV file. Now fetching from https://github.com/datasets/country-codes repository. --- continentmap.go | 2 +- scripts/get_continent_map.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/continentmap.go b/continentmap.go index 3da979a..9e66ebf 100644 --- a/continentmap.go +++ b/continentmap.go @@ -1,7 +1,7 @@ package signaling // This file has been automatically generated, do not modify. -// Source: https://datahub.io/core/country-codes/r/country-codes.json +// Source: https://github.com/datasets/country-codes/raw/master/data/country-codes.csv var ( ContinentMap = map[string][]string{ diff --git a/scripts/get_continent_map.py b/scripts/get_continent_map.py index 22dead6..3a96224 100755 --- a/scripts/get_continent_map.py +++ b/scripts/get_continent_map.py @@ -26,11 +26,11 @@ try: from cStringIO import StringIO except ImportError: from io import StringIO -import json +import csv import subprocess import sys -URL = 'https://datahub.io/core/country-codes/r/country-codes.json' +URL = 'https://github.com/datasets/country-codes/raw/master/data/country-codes.csv' def tostr(s): if isinstance(s, bytes) and not isinstance(s, str): @@ -55,12 +55,13 @@ def generate_map(filename): '-L', URL, ]) - data = json.loads(tostr(data)) + + reader = csv.DictReader(StringIO(tostr(data)), delimiter=',') continents = {} - for entry in data: + for entry in reader: country = entry['ISO3166-1-Alpha-2'] continent = entry['Continent'] - if country is None and continent is None: + if not country and not continent: continue continents.setdefault(country, []).append(continent) From bbdd991f059960702fd4e5caa3d3e6fabe21d3b5 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Mon, 11 Mar 2024 10:39:58 +0100 Subject: [PATCH 2/2] CI: Check continentmap if related files are changed. --- .github/workflows/check-continentmap.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/check-continentmap.yml b/.github/workflows/check-continentmap.yml index 3266793..eff3c10 100644 --- a/.github/workflows/check-continentmap.yml +++ b/.github/workflows/check-continentmap.yml @@ -1,6 +1,18 @@ name: check-continentmap on: + push: + branches: [ master ] + paths: + - '.github/workflows/check-continentmap.yml' + - 'scripts/get_continent_map.py' + - 'Makefile' + pull_request: + branches: [ master ] + paths: + - '.github/workflows/check-continentmap.yml' + - 'scripts/get_continent_map.py' + - 'Makefile' schedule: - cron: "0 2 * * SUN"