B ý|;F‚ã@s€dZddlZddlZdejdd…Zdejdd…ZdZedfdd „Zd d „Zd Z d Z e fdd„Z dd„Z e dkr|e ƒdS)aEnm2def.py Helpers to extract symbols from Unix libs and auto-generate Windows definition files from them. Depends on nm(1). Tested on Linux and Solaris only (-p option to nm is for Solaris only). By Marc-Andre Lemburg, Aug 1998. Additional notes: the output of nm is supposed to look like this: acceler.o: 000001fd T PyGrammar_AddAccelerators U PyGrammar_FindDFA 00000237 T PyGrammar_RemoveAccelerators U _IO_stderr_ U exit U fprintf U free U malloc U printf grammar1.o: 00000000 T PyGrammar_FindDFA 00000034 T PyGrammar_LabelRepr U _PyParser_TokenNames U abort U printf U sprintf ... Even if this isn't the default output of your nm, there is generally an option to produce this format (since it is the original v7 Unix format). éNzlibpython%d.%d.aézPython%d%d.dllz nm -p -g %s)ÚTÚCÚDc Cs‚t t|¡ ¡}dd„|Dƒ}i}xX|D]P}t|ƒdks*d|krDq*| ¡}t|ƒdkrZq*|\}}}||krnq*||f||<q*W|S)NcSsg|] }| ¡‘qS©)Ústrip)Ú.0Úsrrú9/opt/alt/python37/lib64/python3.7/Tools/scripts/nm2def.pyú .szsymbols..rú:é)ÚosÚpopenÚNMÚ readlinesÚlenÚsplit) ÚlibÚtypesÚlinesÚsymbolsÚlineÚitemsZaddressÚtypeÚnamerrr r+s   rcCszg}g}x>| ¡D]2\}\}}|dkr6| d|¡q| d|¡qW| ¡| d¡| ¡d |¡dd |¡S)N)rrú Úz DATA Ú )rÚappendÚsortÚjoin)rÚdataÚcoderZaddrrrrr Ú export_list<s r$z EXPORTS %s rcCsJxDt| ¡ƒD]4}|dd…dksB|dd…dkr4q||kr||=qWdS)NrZPyr Z_Py)ÚlistÚkeys)rZspecialsrrrr Ú filter_PythonUs  r'cCs8ttƒ}t|ƒt|ƒ}tj}| t|¡| ¡dS)N) rÚ PYTHONLIBr'r$ÚsysÚstdoutÚwriteÚ DEF_TEMPLATEÚclose)r ZexportsÚfrrr Úmain]s r/Ú__main__)Ú__doc__rr)Ú version_infor(Z PC_PYTHONLIBrrr$r,ZSPECIALSr'r/Ú__name__rrrr Ú$s