#NEWLINE# def find_deps( outstream , strace_out , show_all ) : #NEWLINE# #INDENT# 'read file witn strace output, return dict with deps, targets' #NEWLINE# regex = re . compile ( ( '.*\\("(?P<file>[^"]*)",' + ' (\\[.*\\])*(?P<mode>[^)]*)\\) = [^-].*' ) ) #NEWLINE# read = set ( ) #NEWLINE# write = set ( ) #NEWLINE# cwd = os . getcwd ( ) #NEWLINE# if ( not os . path . exists ( match ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# with open ( strace_out ) as text : #NEWLINE# #INDENT# for line in text : #NEWLINE# #INDENT# match = regex . match ( line ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# rel_name = match . group ( 'file' ) #NEWLINE# name = os . path . abspath ( rel_name ) #NEWLINE# if ( not show_all ) : #NEWLINE# #INDENT# if ( not name . startswith ( cwd ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# if ( 'WR' in match . group ( 'mode' ) ) : #NEWLINE# #INDENT# if ( name not in write ) : #NEWLINE# #INDENT# write . add ( name ) #NEWLINE# outstream . write ( ( 'W %s\n' % name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name not in read ) : #NEWLINE# #INDENT# read . add ( name ) #NEWLINE# outstream . write ( ( 'R %s\n' % name ) )