def _ansi_expand_style(cmap):
 for (key, val) in list(cmap.items()):
  if (key == 'NO_COLOR'):
   continue
  elif (len(val) == 0):
   cmap[('BOLD_' + key)] = '1'
   cmap[('UNDERLINE_' + key)] = '4'
   cmap[('BOLD_UNDERLINE_' + key)] = '1;4'
   cmap[('BACKGROUND_' + key)] = val
  else:
   cmap[('BOLD_' + key)] = ('1;' + val)
   cmap[('UNDERLINE_' + key)] = ('4;' + val)
   cmap[('BOLD_UNDERLINE_' + key)] = ('1;4;' + val)
   cmap[('BACKGROUND_' + key)] = val.replace('38', '48', 1)

def _ansi_expand_style ( cmap ) : for ( key , val ) in list ( cmap . items ( ) ) : if ( key == 'NO_COLOR' ) : continue elif ( len ( val ) == 0 ) : cmap [ ( 'BOLD_' + key ) ] = '1' cmap [ ( 'UNDERLINE_' + key ) ] = '4' cmap [ ( 'BOLD_UNDERLINE_' + key ) ] = '1;4' cmap [ ( 'BACKGROUND_' + key ) ] = val else : cmap [ ( 'BOLD_' + key ) ] = ( '1;' + val ) cmap [ ( 'UNDERLINE_' + key ) ] = ( '4;' + val ) cmap [ ( 'BOLD_UNDERLINE_' + key ) ] = ( '1;4;' + val ) cmap [ ( 'BACKGROUND_' + key ) ] = val . replace ( '38' , '48' , 1 )
expands a style in order to more quickly make color map changes .