Skip to content

Commit 8498970

Browse files
committed
Replace generators with functions returning lists
1 parent 1681b42 commit 8498970

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Polskie tłumaczenie dokumentacji Pythona
33
<!-- [[[cog
44
from manage_translation import get_resource_language_stats, progress_from_resources, language_switcher, get_number_of_translators
55
6-
stats = list(get_resource_language_stats())
6+
stats = get_resource_language_stats()
77
switcher = progress_from_resources(filter(language_switcher, stats))
88
total = progress_from_resources(stats)
99
translators = get_number_of_translators()

manage_translation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ def _get_tx_token() -> str:
109109
return transifex_api_key
110110

111111

112-
def _get_resources() -> Generator[transifex_api.Resource, None, None]:
112+
def _get_resources() -> list[transifex_api.Resource]:
113113
transifex_api.setup(auth=_get_tx_token())
114-
yield from transifex_api.Resource.filter(project=f'o:python-doc:p:{PROJECT_SLUG}').all()
114+
return transifex_api.Resource.filter(project=f'o:python-doc:p:{PROJECT_SLUG}').all()
115115

116116

117-
def get_resource_language_stats() -> Generator[ResourceLanguageStatistics, None, None]:
117+
def get_resource_language_stats() -> list[ResourceLanguageStatistics]:
118118
transifex_api.setup(auth=_get_tx_token())
119119
resources = transifex_api.ResourceLanguageStats.filter(
120120
project=f'o:python-doc:p:{PROJECT_SLUG}', language=f'l:{LANGUAGE}'
121121
).all()
122-
yield from (ResourceLanguageStatistics.from_api_entry(entry) for entry in resources)
122+
return [ResourceLanguageStatistics.from_api_entry(entry) for entry in resources]
123123

124124

125125
def progress_from_resources(resources: Iterable[ResourceLanguageStatistics]) -> float:

0 commit comments

Comments
 (0)