<s> """<STR_LIT>""" <EOL> import logging <EOL> import dialog <EOL> from certbot . display import util as display_util <EOL> class DialogHandler ( logging . Handler ) : <EOL> """<STR_LIT>""" <EOL> PADDING_HEIGHT = <NUM_LIT:2> <EOL> PADDING_WIDTH = <NUM_LIT:4> <EOL> def __init__ ( self , level = logging . NOTSET , height = display_util . HEIGHT , <EOL> width = display_util . WIDTH - <NUM_LIT:4> , d = None ) : <EOL> logging . Handler . __init__ ( self , level ) <EOL> self . height = height <EOL> self . width = width <EOL> self . d = dialog . Dialog ( ) if d is None else d <EOL> self . lines = [ ] <EOL> def emit ( self , record ) : <EOL> """<STR_LIT>""" <EOL> for line in self . format ( record ) . splitlines ( ) : <EOL> cur_out = line <EOL> while len ( cur_out ) > self . width : <EOL> last_space_pos = cur_out . rfind ( '<STR_LIT:U+0020>' , <NUM_LIT:0> , self . width ) <EOL> if last_space_pos == - <NUM_LIT:1> : <EOL> self . lines . append ( cur_out [ <NUM_LIT:0> : self . width ] ) <EOL> cur_out = cur_out [ self . width : ] <EOL> else : <EOL> self . lines . append ( cur_out [ <NUM_LIT:0> : last_space_pos ] ) <EOL> cur_out = cur_out [ last_space_pos + <NUM_LIT:1> : ] <EOL> if cur_out != '<STR_LIT>' : <EOL> self . lines . append ( cur_out ) <EOL> content = '<STR_LIT:\n>' . join ( self . lines [ - self . height : ] ) <EOL> self . d . infobox ( <EOL> content , self . height + self . PADDING_HEIGHT , <EOL> self . width + self . PADDING_WIDTH ) </s>
