<s> """<STR_LIT>""" <EOL> from datetime import datetime <EOL> import inspect <EOL> filopt = dict ( ) <EOL> stdopt = dict ( ) <EOL> filopt [ '<STR_LIT>' ] = <NUM_LIT:2> <EOL> filopt [ '<STR_LIT>' ] = True <EOL> filopt [ '<STR_LIT>' ] = True <EOL> filopt [ '<STR_LIT>' ] = True <EOL> filopt [ '<STR_LIT>' ] = True <EOL> filopt [ '<STR_LIT>' ] = False <EOL> stdopt [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> stdopt [ '<STR_LIT>' ] = False <EOL> stdopt [ '<STR_LIT>' ] = False <EOL> stdopt [ '<STR_LIT>' ] = False <EOL> stdopt [ '<STR_LIT>' ] = False <EOL> stdopt [ '<STR_LIT>' ] = False <EOL> base_stack_level = - <NUM_LIT:1> <EOL> lastmsg = None <EOL> termcolor = '<STR_LIT>' <EOL> logfilename = '<STR_LIT>' <EOL> logfile = None <EOL> from inspect import stack <EOL> def colorize ( txt ) : <EOL> return txt <EOL> def insertBreak ( ) : <EOL> global filopt <EOL> if filopt [ '<STR_LIT>' ] > - <NUM_LIT:1> : <EOL> ostr = '<STR_LIT:\n>' <EOL> try : <EOL> logfile . write ( ostr + '<STR_LIT:\n>' ) <EOL> except : <EOL> pass <EOL> print ( '<STR_LIT:\n>' ) <EOL> def makeLogString ( string , logopt , caller , callerStack , curr_lev ) : <EOL> outstr = '<STR_LIT>' <EOL> if logopt [ '<STR_LIT>' ] : <EOL> outstr += str ( curr_lev ) <EOL> if logopt [ '<STR_LIT>' ] : <EOL> outstr += '<STR_LIT:U+0020>' * curr_lev <EOL> if logopt [ '<STR_LIT>' ] or logopt [ '<STR_LIT>' ] : <EOL> outstr += '<STR_LIT:U+0020>' <EOL> if logopt [ '<STR_LIT>' ] : <EOL> outstr += str ( datetime . today ( ) ) [ <NUM_LIT:11> : - <NUM_LIT:7> ] <EOL> if logopt [ '<STR_LIT>' ] : <EOL> if logopt [ '<STR_LIT>' ] : <EOL> outstr += '<STR_LIT:U+002CU+0020>' <EOL> if logopt [ '<STR_LIT>' ] : <EOL> outstr += callerStack <EOL> else : <EOL> outstr += caller <EOL> outstr += '<STR_LIT:]>' <EOL> if string == '<STR_LIT>' : <EOL> outstr += '<STR_LIT:I>' '<STR_LIT>' <EOL> else : <EOL> if outstr != '<STR_LIT>' : <EOL> outstr += '<STR_LIT:U+0020>' + string <EOL> else : <EOL> outstr += string <EOL> return outstr <EOL> def send ( string = '<STR_LIT>' , verbosity = <NUM_LIT:1> ) : <EOL> global base_stack_level , lastmsg , stdopt , filopt <EOL> if verbosity <= filopt [ '<STR_LIT>' ] or verbosity <= stdopt [ '<STR_LIT>' ] : <EOL> if stdopt [ '<STR_LIT>' ] or filopt [ '<STR_LIT>' ] : <EOL> if len ( stack ( ) ) <= base_stack_level or base_stack_level == - <NUM_LIT:1> : <EOL> base_stack_level = len ( stack ( ) ) <EOL> curr_lev = len ( stack ( ) ) - base_stack_level <EOL> caller = inspect . stack ( ) [ <NUM_LIT:1> ] [ <NUM_LIT:3> ] <EOL> else : <EOL> caller = '<STR_LIT>' <EOL> curr_lev = <NUM_LIT:0> <EOL> if stdopt [ '<STR_LIT>' ] or filopt [ '<STR_LIT>' ] : <EOL> callerstack = getStackPath ( ) [ <NUM_LIT:2> : ] <EOL> if '<STR_LIT>' in callerstack : <EOL> del ( callerstack [ callerstack . index ( '<STR_LIT>' ) : ] ) <EOL> if '<STR_LIT>' in callerstack : <EOL> del ( callerstack [ callerstack . index ( '<STR_LIT>' ) : ] ) <EOL> callerstack = str ( callerstack ) . strip ( '<STR_LIT>' ) . replace ( '<STR_LIT:U+002CU+0020>' , '<STR_LIT:.>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> callerstack = '<STR_LIT>' <EOL> if verbosity <= filopt [ '<STR_LIT>' ] : <EOL> try : <EOL> outstr_file = makeLogString ( string , filopt , caller , callerstack , curr_lev ) <EOL> logfile . write ( outstr_file + '<STR_LIT:\n>' ) <EOL> except : <EOL> pass <EOL> if verbosity <= stdopt [ '<STR_LIT>' ] : <EOL> outstr_std = makeLogString ( string , stdopt , caller , callerstack , curr_lev ) <EOL> print ( colorize ( outstr_std ) ) <EOL> lastmsg = string <EOL> def startline ( ) : <EOL> global filopt , logfile , logfilename <EOL> if filopt [ '<STR_LIT>' ] > - <NUM_LIT:1> : <EOL> ostr = '<STR_LIT>' + str ( datetime . today ( ) ) [ <NUM_LIT:0> : - <NUM_LIT:7> ] + '<STR_LIT>' <EOL> logfile = open ( logfilename , '<STR_LIT:a>' ) <EOL> logfile . write ( ostr + '<STR_LIT:\n>' ) <EOL> def endline ( ) : <EOL> global filopt , logfile <EOL> if filopt [ '<STR_LIT>' ] > - <NUM_LIT:1> : <EOL> ostr = '<STR_LIT>' + str ( datetime . today ( ) ) [ <NUM_LIT:0> : - <NUM_LIT:7> ] + '<STR_LIT>' <EOL> logfile . write ( ostr + '<STR_LIT:\n>' ) <EOL> logfile . close ( ) <EOL> def getStackPath ( ) : <EOL> path = list ( ) <EOL> for frame in inspect . stack ( ) : <EOL> path . append ( frame [ <NUM_LIT:3> ] ) <EOL> return path </s>
