#NEWLINE# def depends( func ) : #NEWLINE# #INDENT# '\n    Decorator to perform check on infile and outfile. When infile is not present, issue\n    warning, and when outfile is present, skip function calls.\n    ' #NEWLINE# from jcvi.apps.base import need_update , listify #NEWLINE# infile = 'infile' #NEWLINE# outfile = 'outfile' #NEWLINE# def wrapper( * args , **kwargs ) : #NEWLINE# #INDENT# assert ( outfile in kwargs ) , 'You need to specify `outfile=` on function call' #NEWLINE# if ( infile in kwargs ) : #NEWLINE# #INDENT# infilename = listify ( kwargs [ infile ] ) #NEWLINE# for x in infilename : #NEWLINE# #INDENT# assert op . exists ( x ) , 'The specified infile `{0}` does not exist' . format ( x ) #NEWLINE# #UNINDENT# #UNINDENT# outfilename = kwargs [ outfile ] #NEWLINE# if need_update ( infilename , outfilename ) : #NEWLINE# #INDENT# return func ( * args , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = 'File `{0}` exists. Computation skipped.' . format ( outfilename ) #NEWLINE# logging . debug ( msg ) #NEWLINE# #UNINDENT# outfilename = listify ( outfilename ) #NEWLINE# for x in outfilename : #NEWLINE# #INDENT# assert op . exists ( x ) , 'Something went wrong, `{0}` not found' . format ( x ) #NEWLINE# #UNINDENT# return outfilename #NEWLINE# #UNINDENT# return infile