<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> from __future__ import division <EOL> import os <EOL> from datetime import datetime <EOL> from pycopia import methods <EOL> class DebugLogWindow ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , do_stderr = False ) : <EOL> self . _do_stderr = do_stderr <EOL> self . _fo = None <EOL> def __del__ ( self ) : <EOL> self . close ( ) <EOL> def fileno ( self ) : <EOL> if self . _fo is not None : <EOL> return self . _fo . fileno ( ) <EOL> else : <EOL> return - <NUM_LIT:1> <EOL> def close ( self ) : <EOL> if self . _fo is not None : <EOL> fo = self . _fo <EOL> self . _fo = None <EOL> fo . close ( ) <EOL> if self . _do_stderr : <EOL> os . close ( <NUM_LIT:2> ) <EOL> os . dup2 ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> def __call__ ( self , * objs ) : <EOL> if self . _fo is None : <EOL> masterfd , slavefd = os . openpty ( ) <EOL> pid = os . fork ( ) <EOL> if pid : <EOL> os . close ( masterfd ) <EOL> self . _fo = os . fdopen ( slavefd , "<STR_LIT>" , <NUM_LIT:0> ) <EOL> if self . _do_stderr : <EOL> os . close ( <NUM_LIT:2> ) <EOL> os . dup2 ( slavefd , <NUM_LIT:2> ) <EOL> else : <EOL> os . close ( slavefd ) <EOL> os . execlp ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , str ( masterfd ) ) <EOL> fo = self . _fo <EOL> fo . write ( "<STR_LIT>" . format ( datetime . now ( ) ) . encode ( "<STR_LIT:utf-8>" ) ) <EOL> lo = len ( objs ) - <NUM_LIT:1> <EOL> for i , o in enumerate ( objs ) : <EOL> fo . write ( repr ( o ) . encode ( "<STR_LIT:utf-8>" ) ) <EOL> if i < lo : <EOL> fo . write ( b"<STR_LIT:U+002CU+0020>" ) <EOL> fo . write ( b"<STR_LIT:\n>" ) <EOL> def _debug_builder ( * args ) : <EOL> global DEBUG <EOL> if DEBUG is _debug_builder : <EOL> DEBUG = DebugLogWindow ( ) <EOL> DEBUG ( * args ) <EOL> DEBUG = _debug_builder <EOL> def logcall ( f ) : <EOL> def _debug ( * args , ** kwargs ) : <EOL> ms = methods . MethodSignature ( f ) <EOL> argdict = ms . get_keyword_arguments ( args , kwargs ) <EOL> DEBUG ( str ( methods . MethodSignature ( f ) ) , <EOL> "<STR_LIT:U+002CU+0020>" . join ( "<STR_LIT>" . format ( t [ <NUM_LIT:0> ] , t [ <NUM_LIT:1> ] ) for t in argdict . items ( ) if t [ <NUM_LIT:0> ] != "<STR_LIT>" ) ) <EOL> return f ( * args , ** kwargs ) <EOL> _debug . __doc__ = f . __doc__ <EOL> return _debug <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import signal <EOL> DEBUG ( b"<STR_LIT>" ) <EOL> DEBUG ( b"<STR_LIT>" , b"<STR_LIT>" ) <EOL> signal . pause ( ) <EOL> DEBUG . close ( ) </s>
