ó 2ÄÈ[c@`s}ddlmZmZmZddlZddlZddlZddlZdZdZ de ej d ƒZ dZ de Zejd e ejƒZejd e ejƒZd „Zd d de gd„Zd„Zejd„Zedkryeƒ\ZZedkrejZneedƒZee ƒeeƒgZeeƒZeeƒ\Z Z!ee e!eeƒndS(i(tdivisiontabsolute_importtprint_functionNsÔ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\.dllcC`sDttjƒdkr´tjdddkrYtjdddkrYtjd\}}q:tjdddkrtjdddkrtjd\}}q:tdƒtdƒn†ttjƒdkr*tjdddkrútjd}d t}q:tjdddkr:d }tjd}q:nd 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(tlentsystargvtprinttpy_vertNone(tlibfiletdeffile((s6/tmp/pip-build-fiC0ax/numpy/numpy/distutils/lib2def.pyt parse_cmd)s"..     tnms-Css python%s.libcC`sDtj|dtdtjdtƒ}|jjƒ}|jjƒ|S(sVReturns the output of nm_cmd via a pipe. nm_output = getnam(nm_cmd = 'nm -Cs py_lib')tshelltstdouttuniversal_newlines(t subprocesstPopentTruetPIPERtreadtclose(tnm_cmdtft nm_output((s6/tmp/pip-build-fiC0ax/numpy/numpy/distutils/lib2def.pytgetnmAs$ cC`sò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((s6/tmp/pip-build-fiC0ax/numpy/numpy/distutils/lib2def.pytparse_nmJs < ,  cC`sYx|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&R$theadertfiletdata_symtfunc_sym((s6/tmp/pip-build-fiC0ax/numpy/numpy/distutils/lib2def.pyt output_def`s    t__main__tw("t __future__RRRtreRtosRt__doc__t __version__ttuplet version_infoRt DEFAULT_NMt DEF_HEADERtcompilet MULTILINERRR RR'RR-t__name__R R RtopentstrRRR&R$(((s6/tmp/pip-build-fiC0ax/numpy/numpy/distutils/lib2def.pyts0