countries in timezones.py
sometime country name in mirrors.json not in timezones.py
Script for test when new country is added in .json and if bad change timezones.py
run in /tests/test_countries.py (but not is a unittest)
#!/usr/bin/python
import sys
import importlib.util
import json
import urllib.request
def load_module(file_name: str, module_name: str):
spec = importlib.util.spec_from_file_location(module_name, file_name)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
return module
contries_mod = load_module("../pacman_mirrors/constants/timezones.py", "countries_mod")
# print(contries_mod.countries)
countries_ref = sorted({tm['name'].replace(' ','_') for tm in contries_mod.countries})
print("All countries in Application (constants/timezones.py)")
print(' '.join(countries_ref))
print()
countries_mirrors = []
with urllib.request.urlopen('https://gitlab.manjaro.org/webpage/manjaro-web-repo/-/raw/master/mirrors.json') as resp:
countries_mirrors = sorted({m['country'] for m in json.loads(resp.read().decode())})
print("All countries in json")
print(' '.join(countries_mirrors))
print()
err = 0
for country in countries_mirrors:
if country not in countries_ref:
print(f"Err: {country} , not in constants/timezones.py")
if country != 'Global':
err = 1
exit(err)
result :
Err: China , not in constants/timezones.py
Err: Czech , not in constants/timezones.py
Err: Global , not in constants/timezones.py
Err: Netherlands , not in constants/timezones.py
for Global ok, is a good idea to add this country with Global continent ?