mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Allow configuring country and language in core config (#81734)
* Allow configuring country and language in core config * Add script for updating list of countries * Use black for formatting * Fix quoting * Move country codes to a separate file * Address review comments * Add generated/countries.py * Get default language from owner account * Remove unused variable * Add script to generate list of supported languages * Add tests * Fix stale docsring * Use format_python_namespace * Correct async_user_store * Improve typing * Fix with_store decorator * Initialize language in core store migration * Fix startup * Tweak * Apply suggestions from code review Co-authored-by: Franck Nijhof <git@frenck.dev> * Update storage.py Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
27
script/countries.py
Normal file
27
script/countries.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""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,
|
||||
)
|
||||
)
|
Reference in New Issue
Block a user