#NEWLINE# def grep_stdout( func ) : #NEWLINE# #INDENT# '\n    Wrap stderr and stdout to a str return value.\n    :param func:\n    ' #NEWLINE# def wrap( * args ) : #NEWLINE# #INDENT# '\n        Wraps a function.\n\n        :param args: Bunch of Arguments.\n        ' #NEWLINE# old_out = sys . stdout #NEWLINE# old_err = sys . stderr #NEWLINE# sys . stdout = StringIO . StringIO ( ) #NEWLINE# sys . stderr = StringIO . StringIO ( ) #NEWLINE# func ( * args ) #NEWLINE# err = sys . stderr . getvalue ( ) #NEWLINE# out = sys . stdout . getvalue ( ) . strip ( ) . split ( '\n' ) #NEWLINE# sys . stdout . close ( ) #NEWLINE# sys . stderr . close ( ) #NEWLINE# sys . stdout = old_out #NEWLINE# sys . stderr = old_err #NEWLINE# return ( out , err ) #NEWLINE# #UNINDENT# return func