python34gen.py 663 Bytes
Newer Older
1
# Generate python34stub.def out of python3.def
Antoine Pitrou's avatar
Antoine Pitrou committed
2 3 4
# The regular import library cannot be used,
# since it doesn't provide the right symbols for
# data forwarding
5 6
out = open("python34stub.def", "w")
out.write('LIBRARY "python34"\n')
Antoine Pitrou's avatar
Antoine Pitrou committed
7 8 9 10
out.write('EXPORTS\n')

inp = open("python3.def")
line = inp.readline()
11 12 13
while line.strip().startswith(';'):
    line = inp.readline()
line = inp.readline() # LIBRARY
Antoine Pitrou's avatar
Antoine Pitrou committed
14 15 16
assert line.strip()=='EXPORTS'

for line in inp:
17
    # SYM1=python34.SYM2[ DATA]
Antoine Pitrou's avatar
Antoine Pitrou committed
18 19 20 21 22 23 24 25 26
    head, tail = line.split('.')
    if 'DATA' in tail:
        symbol, tail = tail.split(' ')
    else:
        symbol = tail.strip()
    out.write(symbol+'\n')

inp.close()
out.close()