mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-04-26 19:30:26 +02:00
Merge pull request #177 from strukturag/continentmap-source
Change source of country -> continent map.
This commit is contained in:
commit
468470d128
|
@ -1,7 +1,7 @@
|
|||
package signaling
|
||||
|
||||
// This file has been automatically generated, do not modify.
|
||||
// Source: https://datahub.io/JohnSnowLabs/country-and-continent-codes-list/r/country-and-continent-codes-list-csv.json
|
||||
// Source: https://datahub.io/core/country-codes/r/country-codes.json
|
||||
|
||||
var (
|
||||
ContinentMap map[string][]string = map[string][]string{
|
||||
|
@ -11,8 +11,7 @@ var (
|
|||
"AG": {"NA"},
|
||||
"AI": {"NA"},
|
||||
"AL": {"EU"},
|
||||
"AM": {"EU", "AS"},
|
||||
"AN": {"NA"},
|
||||
"AM": {"AS"},
|
||||
"AO": {"AF"},
|
||||
"AQ": {"AN"},
|
||||
"AR": {"SA"},
|
||||
|
@ -21,7 +20,7 @@ var (
|
|||
"AU": {"OC"},
|
||||
"AW": {"NA"},
|
||||
"AX": {"EU"},
|
||||
"AZ": {"EU", "AS"},
|
||||
"AZ": {"AS"},
|
||||
"BA": {"EU"},
|
||||
"BB": {"NA"},
|
||||
"BD": {"AS"},
|
||||
|
@ -59,8 +58,8 @@ var (
|
|||
"CU": {"NA"},
|
||||
"CV": {"AF"},
|
||||
"CW": {"NA"},
|
||||
"CX": {"AS"},
|
||||
"CY": {"EU", "AS"},
|
||||
"CX": {"OC"},
|
||||
"CY": {"EU"},
|
||||
"CZ": {"EU"},
|
||||
"DE": {"EU"},
|
||||
"DJ": {"AF"},
|
||||
|
@ -84,7 +83,7 @@ var (
|
|||
"GA": {"AF"},
|
||||
"GB": {"EU"},
|
||||
"GD": {"NA"},
|
||||
"GE": {"EU", "AS"},
|
||||
"GE": {"AS"},
|
||||
"GF": {"SA"},
|
||||
"GG": {"EU"},
|
||||
"GH": {"AF"},
|
||||
|
@ -130,7 +129,7 @@ var (
|
|||
"KR": {"AS"},
|
||||
"KW": {"AS"},
|
||||
"KY": {"NA"},
|
||||
"KZ": {"EU", "AS"},
|
||||
"KZ": {"AS"},
|
||||
"LA": {"AS"},
|
||||
"LB": {"AS"},
|
||||
"LC": {"NA"},
|
||||
|
@ -196,7 +195,7 @@ var (
|
|||
"RE": {"AF"},
|
||||
"RO": {"EU"},
|
||||
"RS": {"EU"},
|
||||
"RU": {"EU", "AS"},
|
||||
"RU": {"EU"},
|
||||
"RW": {"AF"},
|
||||
"SA": {"AS"},
|
||||
"SB": {"OC"},
|
||||
|
@ -226,18 +225,18 @@ var (
|
|||
"TH": {"AS"},
|
||||
"TJ": {"AS"},
|
||||
"TK": {"OC"},
|
||||
"TL": {"AS"},
|
||||
"TL": {"OC"},
|
||||
"TM": {"AS"},
|
||||
"TN": {"AF"},
|
||||
"TO": {"OC"},
|
||||
"TR": {"EU", "AS"},
|
||||
"TR": {"AS"},
|
||||
"TT": {"NA"},
|
||||
"TV": {"OC"},
|
||||
"TW": {"AS"},
|
||||
"TZ": {"AF"},
|
||||
"UA": {"EU"},
|
||||
"UG": {"AF"},
|
||||
"UM": {"OC", "NA"},
|
||||
"UM": {"OC"},
|
||||
"US": {"NA"},
|
||||
"UY": {"SA"},
|
||||
"UZ": {"AS"},
|
||||
|
@ -250,10 +249,6 @@ var (
|
|||
"VU": {"OC"},
|
||||
"WF": {"OC"},
|
||||
"WS": {"OC"},
|
||||
"XD": {"AS"},
|
||||
"XE": {"AS"},
|
||||
"XS": {"AS"},
|
||||
"XX": {"OC"},
|
||||
"YE": {"AS"},
|
||||
"YT": {"AF"},
|
||||
"ZA": {"AF"},
|
||||
|
|
|
@ -104,7 +104,7 @@ func TestGeoLookupContinent(t *testing.T) {
|
|||
tests := map[string][]string{
|
||||
"AU": {"OC"},
|
||||
"DE": {"EU"},
|
||||
"RU": {"EU", "AS"},
|
||||
"RU": {"EU"},
|
||||
"": nil,
|
||||
"INVALID ": nil,
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@ func Test_sortConnectionsForCountry(t *testing.T) {
|
|||
{conn_de, conn_jp, conn_at},
|
||||
{conn_jp, conn_de, conn_at},
|
||||
},
|
||||
// Partial continent match
|
||||
// Continent match
|
||||
"RU": {
|
||||
{conn_us, conn_de, conn_jp, conn_at},
|
||||
{conn_de, conn_jp, conn_at, conn_us},
|
||||
{conn_de, conn_at, conn_us, conn_jp},
|
||||
},
|
||||
// No match
|
||||
"AU": {
|
||||
|
@ -125,10 +125,10 @@ func Test_sortConnectionsForCountryWithOverride(t *testing.T) {
|
|||
{conn_de, conn_jp, conn_at},
|
||||
{conn_jp, conn_de, conn_at},
|
||||
},
|
||||
// Partial continent match
|
||||
// Continent match
|
||||
"RU": {
|
||||
{conn_us, conn_de, conn_jp, conn_at},
|
||||
{conn_de, conn_jp, conn_at, conn_us},
|
||||
{conn_de, conn_at, conn_us, conn_jp},
|
||||
},
|
||||
// No match
|
||||
"AR": {
|
||||
|
|
|
@ -30,7 +30,7 @@ import json
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
URL = 'https://datahub.io/JohnSnowLabs/country-and-continent-codes-list/r/country-and-continent-codes-list-csv.json'
|
||||
URL = 'https://datahub.io/core/country-codes/r/country-codes.json'
|
||||
|
||||
def tostr(s):
|
||||
if isinstance(s, bytes) and not isinstance(s, str):
|
||||
|
@ -58,8 +58,11 @@ def generate_map(filename):
|
|||
data = json.loads(tostr(data))
|
||||
continents = {}
|
||||
for entry in data:
|
||||
country = entry['Two_Letter_Country_Code']
|
||||
continent = entry['Continent_Code']
|
||||
country = entry['ISO3166-1-Alpha-2']
|
||||
continent = entry['Continent']
|
||||
if country is None and continent is None:
|
||||
continue
|
||||
|
||||
continents.setdefault(country, []).append(continent)
|
||||
|
||||
out = StringIO()
|
||||
|
|
Loading…
Reference in a new issue