Merge pull request #1441 from onionshare/update-weblate-script

Update weblate script to make the output more
This commit is contained in:
Micah Lee 2021-10-11 19:01:08 -07:00 committed by GitHub
commit 357e3efead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@
import sys import sys
import httpx import httpx
import asyncio import asyncio
import time
api_token = None api_token = None
@ -63,41 +62,33 @@ async def app_percent_output(percent_min, percent_max=101):
print("") print("")
async def docs_percent_output(percent_min, exclude=[]): async def docs_percent_output(percent_min, percent_max=101):
out = [] out = []
for lang_code in languages: for lang_code in languages:
include_language = True
percentages = [] percentages = []
for component in docs_translations: for component in docs_translations:
if lang_code not in docs_translations[component]: if lang_code in docs_translations[component]:
include_language = False percentages.append(docs_translations[component][lang_code])
break else:
percentages.append(0)
percentages.append(docs_translations[component][lang_code]) average_percentage = int(sum(percentages) / len(percentages))
if docs_translations[component][lang_code] < percent_min: if (
include_language = False average_percentage != 0
break and average_percentage >= percent_min
and average_percentage < percent_max
):
out.append(f"{languages[lang_code]} ({lang_code}), {average_percentage}%")
if include_language: out.sort()
percentages = [f"{p}%" for p in percentages]
percentages = ", ".join(percentages)
out.append(f"{languages[lang_code]} ({lang_code}), {percentages}")
excluded = []
for s in out:
if s not in exclude:
excluded.append(s)
excluded.sort()
print(f"Docs translations >= {percent_min}%") print(f"Docs translations >= {percent_min}%")
print("========================") print("========================")
print("\n".join(excluded)) print("\n".join(out))
print("") print("")
return excluded
async def main(): async def main():
@ -140,13 +131,13 @@ async def main():
print("") print("")
# await app_percent_output(100)
await app_percent_output(90, 101) await app_percent_output(90, 101)
await app_percent_output(80, 90) await app_percent_output(50, 90)
await app_percent_output(0, 50)
out100 = await docs_percent_output(100) await docs_percent_output(90, 101)
out90 = await docs_percent_output(90, out100) await docs_percent_output(50, 90)
await docs_percent_output(80, out100 + out90) await docs_percent_output(0, 50)
if __name__ == "__main__": if __name__ == "__main__":