Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 import sys, re
00024
00025 def main():
00026 if len(sys.argv) != 3:
00027 print 'usage: makedocstrings infile outfile'
00028
00029 infile = open(sys.argv[1], 'rt')
00030 outfile = open(sys.argv[2], 'wt')
00031
00032 docstrings = {}
00033
00034 while 1:
00035 line = infile.readline()
00036 if not line:
00037 break
00038 m = re.match(r'#define _doc_([a-zA-Z_0-9]+)', line)
00039 if m:
00040 name = m.group(1)
00041 value = '_doc_'+name
00042 docstrings[name] = value
00043
00044
00045 if re.match(r'static PyMethodDef SwigMethods', line):
00046 outfile.write(line)
00047
00048 while 1:
00049 line = infile.readline()
00050 m = re.match('[ \t]+\{[ \t]\(char \*\)"([a-zA-Z_0-9]+)"(.*)\,[ ]*NULL[ ]*\},', line)
00051 if not m:
00052 m = re.match('[ \t]+\{[ \t]\(char \*\)"([a-zA-Z_0-9]+)"(.*)\},', line)
00053 if not m:
00054 break
00055 func = m.group(1)
00056
00057 if func in docstrings.keys():
00058 line = '\t{ (char *)"%s"%s, %s },\n' % (func, m.group(2), docstrings[func])
00059 outfile.write(line)
00060
00061 outfile.write(line)
00062
00063 if __name__ == '__main__':
00064 main()