-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcheck.py
executable file
·45 lines (36 loc) · 952 Bytes
/
check.py
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
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3.2
# -*- coding: utf-8 -*-
import glob
def getKeys(filename):
fd = open(filename)
keys = []
for line in fd:
line = line.strip()
if line.startswith("#") or not '=' in line:
continue
key, val = line.split('=', 1)
keys += [key]
return set(keys)
en = "en_US.lang"
langfiles = glob.glob("*.lang")
langfiles.remove(en)
en_keys = getKeys(en)
formatKey = lambda x: "\t" + x + (" (may be fine)" if x.endswith(".hint") or x.endswith(".shift") else "")
def sort(s):
l = list(s)
l.sort()
return l
for lang in langfiles:
keys = getKeys(lang)
invalid_keys = sort(keys.difference(en_keys))
if invalid_keys:
print("Extra keys in {0}:".format(lang))
for k in invalid_keys:
print(formatKey(k))
print()
missing_keys = sort(en_keys.difference(keys))
if missing_keys:
print("Missing keys in {0}:".format(lang))
for k in missing_keys:
print("\t" + k)
print()