<s> """<STR_LIT>""" <EOL> esc = "<STR_LIT>" <EOL> codes = { } <EOL> codes [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> codes [ "<STR_LIT>" ] = esc + "<STR_LIT>" <EOL> dark_colors = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> light_colors = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> x = <NUM_LIT:30> <EOL> for d , l in zip ( dark_colors , light_colors ) : <EOL> codes [ d ] = esc + "<STR_LIT>" % x <EOL> codes [ l ] = esc + "<STR_LIT>" % x <EOL> x += <NUM_LIT:1> <EOL> del d , l , x <EOL> codes [ "<STR_LIT>" ] = codes [ "<STR_LIT>" ] <EOL> codes [ "<STR_LIT>" ] = codes [ "<STR_LIT>" ] <EOL> codes [ "<STR_LIT>" ] = codes [ "<STR_LIT>" ] <EOL> codes [ "<STR_LIT>" ] = codes [ "<STR_LIT>" ] <EOL> def reset_color ( ) : <EOL> return codes [ "<STR_LIT>" ] <EOL> def colorize ( color_key , text ) : <EOL> return codes [ color_key ] + text + codes [ "<STR_LIT>" ] <EOL> def ansiformat ( attr , text ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> if attr [ : <NUM_LIT:1> ] == attr [ - <NUM_LIT:1> : ] == '<STR_LIT:+>' : <EOL> result . append ( codes [ '<STR_LIT>' ] ) <EOL> attr = attr [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> if attr [ : <NUM_LIT:1> ] == attr [ - <NUM_LIT:1> : ] == '<STR_LIT:*>' : <EOL> result . append ( codes [ '<STR_LIT>' ] ) <EOL> attr = attr [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> if attr [ : <NUM_LIT:1> ] == attr [ - <NUM_LIT:1> : ] == '<STR_LIT:_>' : <EOL> result . append ( codes [ '<STR_LIT>' ] ) <EOL> attr = attr [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> result . append ( codes [ attr ] ) <EOL> result . append ( text ) <EOL> result . append ( codes [ '<STR_LIT>' ] ) <EOL> return '<STR_LIT>' . join ( result ) </s>
