-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Expand file tree
/
Copy pathcountries.py
More file actions
29 lines (21 loc) · 779 Bytes
/
countries.py
File metadata and controls
29 lines (21 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Helper script to update country list.
ISO does not publish a machine readable list free of charge, so the list is generated
with help of the pycountry package.
"""
from pathlib import Path
import pycountry
from .hassfest.serializer import format_python_namespace
countries = {x.alpha_2 for x in pycountry.countries}
generator_string = """script.countries
The values are directly corresponding to the ISO 3166 standard. If you need changes
to the political situation in the world, please contact the ISO 3166 working group.
"""
Path("homeassistant/generated/countries.py").write_text(
format_python_namespace(
{
"COUNTRIES": countries,
},
generator=generator_string,
annotations={"COUNTRIES": "Final[set[str]]"},
)
)