Logo Search packages:      
Sourcecode: kanjisaver version File versions  Download package

superweirdsub.py

#!/usr/bin/env python
# weird sub for kanji.h file

import sys, re, string, os

kanjif = open(sys.argv[1], 'r')
kanjif = kanjif.readlines()

# hiragana part
kanao = open('hiragana_output', 'r')
kanao = kanao.readlines()
kanar = open('hiragana_outputRMJI', 'r')
kanar = kanar.readlines()

counter = 0
for line in kanjif:
      if line[0:2] != '{"':
            continue
      rline = line
      rline = re.sub(',"",', ',"%s",' %(kanar[counter].strip('\n')), rline, 1)
      kanjif[kanjif.index(line)] = rline
      counter += 1

# katakana part
kanao = open('katakana_output', 'r')
kanao = kanao.readlines()
kanar = open('katakana_outputRMJI', 'r')
kanar = kanar.readlines()

counter = 0
for line in kanjif:
      if line[0:2] != '{"':
            continue
      if kanar[counter].strip('\n') == '':
            continue
      rline = line
      rline = re.sub(',""}', ',"%s"}' %(kanar[counter].strip('\n')), rline, 1)
      kanjif[kanjif.index(line)] = rline
      counter += 1

f = open('roma_kanji.h', 'w')
f.writelines(kanjif)
f.close()


Generated by  Doxygen 1.6.0   Back to index