-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkjson.py
executable file
·52 lines (42 loc) · 1.17 KB
/
mkjson.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
52
#!/usr/bin/env python3
"""
MKSJON
mkjson creates chess opening classification JSON file from the Python library.
"""
__author__ = 'Ari Makela'
__copyright__ = 'Copyright 2017-2021'
__credits__ = ['Ari Makela']
__license__ = 'GPL'
__version__ = '0.1.0'
__maintainer__ = 'Ari Makela'
__email__ = 'ari.makela@iki.fi'
__status__ = 'Development'
import json
import logging
import sys
import openingclassification
logging.basicConfig(level=logging.DEBUG)
def main():
"""The main function."""
items = dict()
for fen, nic_key in openingclassification.NIC_DATA.items():
item = dict()
item['nic'] = nic_key
items[fen] = item
for fen, eco_key in openingclassification.ECO_DATA.items():
if fen in items:
items[fen]['eco'] = eco_key
else:
item = dict()
item['eco'] = eco_key
items[fen] = item
for fen, name in openingclassification.LONG_NAME_DATA.items():
if fen in items:
items[fen]['name'] = name
else:
item = dict()
item['name'] = name
items[fen] = item
json.dump(items, sys.stdout)
if __name__ == '__main__':
main()