mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-17 04:56:33 +02:00
Update source of continentmap to original CSV file.
Now fetching from https://github.com/datasets/country-codes repository.
This commit is contained in:
parent
1fa731f20e
commit
b0f2e6ea33
|
@ -1,7 +1,7 @@
|
||||||
package signaling
|
package signaling
|
||||||
|
|
||||||
// This file has been automatically generated, do not modify.
|
// 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 (
|
var (
|
||||||
ContinentMap = map[string][]string{
|
ContinentMap = map[string][]string{
|
||||||
|
|
|
@ -26,11 +26,11 @@ try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import json
|
import csv
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
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):
|
def tostr(s):
|
||||||
if isinstance(s, bytes) and not isinstance(s, str):
|
if isinstance(s, bytes) and not isinstance(s, str):
|
||||||
|
@ -55,12 +55,13 @@ def generate_map(filename):
|
||||||
'-L',
|
'-L',
|
||||||
URL,
|
URL,
|
||||||
])
|
])
|
||||||
data = json.loads(tostr(data))
|
|
||||||
|
reader = csv.DictReader(StringIO(tostr(data)), delimiter=',')
|
||||||
continents = {}
|
continents = {}
|
||||||
for entry in data:
|
for entry in reader:
|
||||||
country = entry['ISO3166-1-Alpha-2']
|
country = entry['ISO3166-1-Alpha-2']
|
||||||
continent = entry['Continent']
|
continent = entry['Continent']
|
||||||
if country is None and continent is None:
|
if not country and not continent:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
continents.setdefault(country, []).append(continent)
|
continents.setdefault(country, []).append(continent)
|
||||||
|
|
Loading…
Reference in a new issue