Skip to content

Commit 23b13a2

Browse files
hugovkm-aciek
andauthored
Update get_languages to return generator of language codes in switcher
Co-authored-by: Maciej Olko <[email protected]>
1 parent 23d71b2 commit 23b13a2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

switcher.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@
1111
import requests
1212

1313

14-
def get_languages() -> defaultdict[str, bool]:
15-
# Languages missing from config.toml are not in production
16-
in_prod = defaultdict(lambda: False)
14+
def get_languages() -> Generator[str, None, None]:
1715
data = requests.get(
1816
"https://raw.githubusercontent.com/"
1917
"python/docsbuild-scripts/refs/heads/main/config.toml",
2018
timeout=10,
2119
).text
22-
languages = tomllib.loads(data)["languages"]
20+
config = tomllib.loads(data)
21+
languages = config["languages"]
22+
defaults = config["defaults"]
2323
for code, language in languages.items():
24-
code = code.lower().replace("_", "-")
25-
# Languages in config.toml default to being in production
26-
in_prod[code] = language.get("in_prod", True)
27-
return in_prod
24+
if language.get("in_prod", defaults["in_prod"]):
25+
yield code.lower().replace("_", "-")
2826

2927

3028
def main() -> None:

0 commit comments

Comments
 (0)