from __future__ import with_statement import struct import sys def convert(input, output): with open(input, "r") as in_file: with open(output, "w") as out_file: def build_dic(parts): dic = {} for part in parts: print parts, part key, value = part.split('=') try: dic[key] = int(value) except: dic[key] = value return dic def get_entry(line): while line[-1] == "\r" or line[-1] == "\n": line = line[0:-1] parts = [] quote = 0 part = "" for c in line: if c == "\"": quote = 1-quote elif c == " " and not quote: if part: parts.append(part) part = "" else: part += c if part: parts.append(part) type = parts[0] dic = build_dic(parts[1:]) return type, dic def write_int16(val): out_file.write(struct.pack(' " else: print "converting..." convert(sys.argv[1], sys.argv[2]) print "done!"