aboutsummaryrefslogtreecommitdiff
path: root/docs/check-weblate.py
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-10-03 14:09:07 -0700
committerMicah Lee <micah@micahflee.com>2021-10-03 14:09:07 -0700
commit8e59cc6b9bebd2838e2ce4e87e66e1f9242f94ca (patch)
tree25deeae94946c8c98cff3b4f81fa6b5c951113fd /docs/check-weblate.py
parent33da57613a403fafd706221fd8633f8d48e172c4 (diff)
downloadonionshare-8e59cc6b9bebd2838e2ce4e87e66e1f9242f94ca.tar.gz
onionshare-8e59cc6b9bebd2838e2ce4e87e66e1f9242f94ca.zip
Update weblate script to make the output more
Diffstat (limited to 'docs/check-weblate.py')
-rwxr-xr-xdocs/check-weblate.py47
1 files changed, 19 insertions, 28 deletions
diff --git a/docs/check-weblate.py b/docs/check-weblate.py
index c5bb255d..ee828f93 100755
--- a/docs/check-weblate.py
+++ b/docs/check-weblate.py
@@ -2,7 +2,6 @@
import sys
import httpx
import asyncio
-import time
api_token = None
@@ -63,41 +62,33 @@ async def app_percent_output(percent_min, percent_max=101):
print("")
-async def docs_percent_output(percent_min, exclude=[]):
+async def docs_percent_output(percent_min, percent_max=101):
out = []
for lang_code in languages:
- include_language = True
percentages = []
for component in docs_translations:
- if lang_code not in docs_translations[component]:
- include_language = False
- break
+ if lang_code in docs_translations[component]:
+ percentages.append(docs_translations[component][lang_code])
+ 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:
- include_language = False
- break
-
- if include_language:
- 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)
+ if (
+ average_percentage != 0
+ and average_percentage >= percent_min
+ and average_percentage < percent_max
+ ):
+ out.append(f"{languages[lang_code]} ({lang_code}), {average_percentage}%")
- excluded.sort()
+ out.sort()
print(f"Docs translations >= {percent_min}%")
print("========================")
- print("\n".join(excluded))
+ print("\n".join(out))
print("")
- return excluded
async def main():
@@ -140,13 +131,13 @@ async def main():
print("")
- # await app_percent_output(100)
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)
- out90 = await docs_percent_output(90, out100)
- await docs_percent_output(80, out100 + out90)
+ await docs_percent_output(90, 101)
+ await docs_percent_output(50, 90)
+ await docs_percent_output(0, 50)
if __name__ == "__main__":