mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Reduce verbosity of translation coverage stats script
This commit is contained in:
parent
5032c1c099
commit
785c5edf96
@ -4,6 +4,7 @@ This script calculates translation coverage for various languages
|
||||
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def calculate_coverage(filename):
|
||||
@ -42,7 +43,7 @@ if __name__ == '__main__':
|
||||
locales = {}
|
||||
locales_perc = {}
|
||||
|
||||
print("InvenTree translation coverage:")
|
||||
verbose = '-v' in sys.argv
|
||||
|
||||
for locale in os.listdir(LC_DIR):
|
||||
path = os.path.join(LC_DIR, locale)
|
||||
@ -53,7 +54,10 @@ if __name__ == '__main__':
|
||||
if os.path.exists(locale_file) and os.path.isfile(locale_file):
|
||||
locales[locale] = locale_file
|
||||
|
||||
print("-" * 16)
|
||||
if verbose:
|
||||
print("-" * 16)
|
||||
|
||||
percentages = []
|
||||
|
||||
for locale in locales.keys():
|
||||
locale_file = locales[locale]
|
||||
@ -66,11 +70,23 @@ if __name__ == '__main__':
|
||||
else:
|
||||
percentage = 0
|
||||
|
||||
print(f"| {locale.ljust(4, ' ')} : {str(percentage).rjust(4, ' ')}% |")
|
||||
if verbose:
|
||||
print(f"| {locale.ljust(4, ' ')} : {str(percentage).rjust(4, ' ')}% |")
|
||||
|
||||
locales_perc[locale] = percentage
|
||||
|
||||
print("-" * 16)
|
||||
percentages.append(percentage)
|
||||
|
||||
if verbose:
|
||||
print("-" * 16)
|
||||
|
||||
# write locale stats
|
||||
with open(STAT_FILE, 'w') as target:
|
||||
json.dump(locales_perc, target)
|
||||
|
||||
if len(percentages) > 0:
|
||||
avg = int(sum(percentages) / len(percentages))
|
||||
else:
|
||||
avg = 0
|
||||
|
||||
print(f"InvenTree translation coverage: {avg}%")
|
Loading…
Reference in New Issue
Block a user