## -*- coding: utf-8 -*-
#(C) 2018 Muthiah Annamalai
# This file is part of Open-Tamil project
# You may use or distribute this file under terms of MIT license

import codecs
import json
import tamil
import sys
import os

#e.g. python morse_encode.py கலைஞர்
CURRDIR = os.path.dirname(os.path.realpath(__file__))
def encode(text):
    with codecs.open(os.path.join(CURRDIR,"data","madurai_tamilmorse.json"),"r","utf-8") as fp:
        codebook = json.loads(fp.read())
    output = [codebook.get(l,l) for l in tamil.utf8.get_letters(text)]
    return u" ".join(output)

if __name__ == u"__main__":
    encode(u" ".join([i.decode("utf-8") for i in sys.argv[1:]]))

[((13, 26, 13, 52), 'os.path.realpath', 'os.path.realpath', ({(13, 43, 13, 51): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((15, 21, 15, 75), 'os.path.join', 'os.path.join', ({(15, 34, 15, 41): 'CURRDIR', (15, 42, 15, 48): '"""data"""', (15, 49, 15, 74): '"""madurai_tamilmorse.json"""'}, {}), "(CURRDIR, 'data', 'madurai_tamilmorse.json')", False, 'import os\n'), ((17, 41, 17, 69), 'tamil.utf8.get_letters', 'tamil.utf8.get_letters', ({(17, 64, 17, 68): 'text'}, {}), '(text)', False, 'import tamil\n')]