#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

import sys
import re
import base64
import types
from EMT import EMTypograph
import json

def main():
    EMT = EMTypograph()

    EMT.setup({
        'Text.paragraphs': 'off',
        'OptAlign.oa_oquote': 'off',
        'Text.breakline': 'off'
    })

    data = json.loads(open('./input.json').read(100000000))
    for k, item in data.items():
        print k
        for text in item['text']:
            EMT.set_text(text['value'])
            text['value'] = EMT.apply()

    # json.dump(data, open('./output.json', 'w'), ensure_ascii=False)
    open('./output.js', 'w').write('export default ' + json.dumps(data, sort_keys = True, ensure_ascii=False).encode('utf-8'))

if __name__=="__main__":
    main()
