Skip to content

Instantly share code, notes, and snippets.

@venj
Created September 5, 2011 06:48
Show Gist options
  • Save venj/1194260 to your computer and use it in GitHub Desktop.
Save venj/1194260 to your computer and use it in GitHub Desktop.
parse raw dict file to xml
from __future__ import division
import sys,os
def decrypt(str):
i=0
tmp=''
try:
while True:
tmp+=chr((255-ord(str[i]))) #XD
i+=1
except IndexError:pass
return tmp
def parse_dict(file):
pointer = 0x404
delDuplicate=False
f=open(file,'rb')
buffer=''
f.seek(pointer)
output_file = file.split(".")[0] + '.xml'
buffer = decrypt(f.read())
rindex = buffer.rfind(r'</word>') + len(r'</word>')
open(output_file, "wb+").write(buffer[:rindex].replace(r'</word>', "</word>\n"))
if len(sys.argv) < 2:
print "Usage: %s dict_file_1 [...]" % sys.argv[0]
exit(1)
sys.argv.pop(0)
for f in sys.argv:
print "Processing: %s" % f
parse_dict(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment