forked from J-Rios/TLG_JoinCaptchaBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlangcheck.py
51 lines (42 loc) · 1.4 KB
/
langcheck.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
45
46
47
48
49
50
51
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###############################################################################
### Imported modules
import json
import os
from constants import CONST
###############################################################################
### Auxiliary Functions
def is_valid(langname, lang, englang):
missing = []
for key in englang:
if key not in lang:
missing.append(key)
if len(missing) == 0:
print("{} is complete".format(langname))
return True
else:
print("{} is missing these keys: {}".format(langname, missing))
return False
###############################################################################
### Main Function
def main():
with open(os.path.join(CONST["LANG_DIR"], "en.json")) as enfile:
en = json.load(enfile)
errs = False
for lang in os.listdir(CONST["LANG_DIR"]):
if not lang.endswith('.json'):
continue
if lang == 'en.json':
continue
with open(os.path.join(CONST["LANG_DIR"], lang)) as langfile:
try:
if not is_valid(lang.split('.')[0], json.load(langfile), en):
errs = True
except json.decoder.JSONDecodeError:
errs = True
print("{} is not valid json".format(lang))
if errs:
exit(1)
if __name__ == '__main__':
main()