#NEWLINE# def osx_syms( libfilename , outfilename ) : #NEWLINE# #INDENT# pe = subprocess . Popen ( [ 'otool' , '-l' , libfilename ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# output = pe . communicate ( ) [ 0 ] . decode ( ) #NEWLINE# if ( pe . returncode != 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Otool does not work.' ) #NEWLINE# #UNINDENT# arr = output . split ( '\n' ) #NEWLINE# for ( i , val ) in enumerate ( arr ) : #NEWLINE# #INDENT# if ( 'LC_ID_DYLIB' in val ) : #NEWLINE# #INDENT# match = i #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# result = [ arr [ ( match + 2 ) ] , arr [ ( match + 5 ) ] ] #NEWLINE# pnm = subprocess . Popen ( [ 'nm' , '-g' , '-P' , libfilename ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# output = pnm . communicate ( ) [ 0 ] . decode ( ) #NEWLINE# if ( pnm . returncode != 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'nm does not work.' ) #NEWLINE# #UNINDENT# result += [ ' ' . join ( x . split ( ) [ 0 : 2 ] ) for x in output . split ( '\n' ) if ( ( len ( x ) > 0 ) and ( not x . endswith ( 'U' ) ) ) ] #NEWLINE# write_if_changed ( ( '\n' . join ( result ) + '\n' ) , outfilename )