File: analyze.py

package info (click to toggle)
ddnet 19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,960 kB
  • sloc: cpp: 195,050; ansic: 58,572; python: 5,568; asm: 946; sh: 941; java: 366; xml: 206; makefile: 31
file content (35 lines) | stat: -rwxr-xr-x 825 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import os
import sys
import twlang

os.chdir(os.path.dirname(__file__) + "/../..")

if len(sys.argv) > 1:
	langs = sys.argv[1:]
else:
	langs = twlang.languages()
local = twlang.localizes()
table = []
for lang in langs:
	trans = twlang.translations(lang)
	empty = 0
	supported = 0
	unused = 0
	for tran, (_, expr, _) in trans.items():
		if not expr:
			empty += 1
		else:
			if tran in local:
				supported += 1
			else:
				unused += 1
	table.append([lang, len(trans), empty, len(local)-supported, unused])

table.sort(key=lambda l: l[3])
table = [["filename", "total", "empty", "missing", "unused"]] + table
s = [[str(e) for e in row] for row in table]
lens = [max(map(len, col)) for col in zip(*s)]
fmt = "    ".join(f"{{:{x}}}" for x in lens)
t = [fmt.format(*row) for row in s]
print("\n".join(t))