ó \ĐKc@saddlZddlZddlZddlZdZdZdeejd ƒZdZ deZ ej deej ƒZ ej d eej ƒZd „Zd d d egd„Zd„Zejd„Zedkr]eƒ\ZZedkrejZneedƒZee ƒeeƒgZeeƒZeeƒ\ZZeeee eƒndS(i˙˙˙˙NsÔThis module generates a DEF file from the symbols in an MSVC-compiled DLL import library. It correctly discriminates between data and functions. The data is collected from the output of the program nm(1). Usage: python lib2def.py [libname.lib] [output.def] or python lib2def.py [libname.lib] > output.def libname.lib defaults to python.lib and output.def defaults to stdout Author: Robert Kern Last Update: April 30, 1999 s0.1as%d%disnm -CssrLIBRARY python%s.dll ;CODE PRELOAD MOVEABLE DISCARDABLE ;DATA PRELOAD SINGLE EXPORTS s^(.*) in python%s\.dlls^_imp__(.*) in python%s\.dllcCs:ttjƒdkrŞtjdddkrYtjdddkrYtjd\}}q0tjdddkrtjdddkrtjd\}}q0dGHdGHn†ttjƒdkr tjdddkrđtjd}d t}q0tjdddkr0d }tjd}q0nd t}d }||fS( sBParses the command-line arguments. libfile, deffile = parse_cmd()iiiü˙˙˙s.libis.defs4I'm assuming that your first argument is the librarysand the second is the DEF file.s python%s.libN(tlentsystargvtpy_vertNone(tlibfiletdeffile((s;/usr/lib/python2.7/site-packages/numpy/distutils/lib2def.pyt parse_cmd's"..   tnms-Css python%s.libcCs>tj|dtdtjƒ}|jjƒ}|jjƒ|S(sVReturns the output of nm_cmd via a pipe. nm_output = getnam(nm_cmd = 'nm -Cs py_lib')tshelltstdout(t subprocesstPopentTruetPIPER treadtclose(tnm_cmdtft nm_output((s;/usr/lib/python2.7/site-packages/numpy/distutils/lib2def.pytgetnm?s cCsňtj|ƒ}tj|ƒ}g}xZ|D]R}||kr+|d dksm|d dksm|d dkr+|j|ƒq+q+Wg}xJ|D]B}||krŽ|d dksŔ|d dkrŽ|j|ƒqŽqŽW|jƒ|jƒ||fS(sŒReturns a tuple of lists: dlist for the list of data symbols and flist for the list of function symbols. dlist, flist = parse_nm(nm_output)itPyit_Pyitinit(tDATA_REtfindalltFUNC_REtappendtsort(Rtdatatfunctflisttsymtdlist((s;/usr/lib/python2.7/site-packages/numpy/distutils/lib2def.pytparse_nmHs < ,  cCsYx|D]}|d|}qW|d}x|D]}|d|}q0W|j|ƒdS(soOutputs the final DEF file to a file defaulting to stdout. output_def(dlist, flist, header, file = sys.stdout)s %s DATA s s %s N(twrite(R!Rtheadertfiletdata_symtfunc_sym((s;/usr/lib/python2.7/site-packages/numpy/distutils/lib2def.pyt output_def^s    t__main__tw(treRtosR t__doc__t __version__ttuplet version_infoRt DEFAULT_NMt DEF_HEADERtcompilet MULTILINERRRRR"R R(t__name__RRRtopentstrRRR!R(((s;/usr/lib/python2.7/site-packages/numpy/distutils/lib2def.pyts.