-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.py
30 lines (26 loc) · 868 Bytes
/
resources.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
import os
def main():
names = list()
with open('resources.js', 'w') as f:
for fname in os.listdir():
if not fname.endswith('.txt'):
continue
name = fname[:-4]
names.append(name)
mapping = dict()
with open(fname) as g:
for line in g:
line = line.strip()
if len(line) > 0:
l, r = line.split('\t')
mapping[l] = r.split(' ')[0]
f.write(f'const {name} = ' + '{\n')
for l, r in mapping.items():
f.write(f' \'{l}\': \'{r}\',\n')
f.write('};\n')
f.write('const dict = {\n')
for name in names:
f.write(f' \'{name}\': {name},\n')
f.write('};\n')
if __name__ == '__main__':
main()