def shorten_comment(line, max_line_length, last_comment=False):
 assert (len(line) > max_line_length)
 line = line.rstrip()
 indentation = (_get_indentation(line) + u'# ')
 max_line_length = min(max_line_length, (len(indentation) + 72))
 MIN_CHARACTER_REPEAT = 5
 if (((len(line) - len(line.rstrip(line[(-1)]))) >= MIN_CHARACTER_REPEAT) and (not line[(-1)].isalnum())):
  return (line[:max_line_length] + u'\n')
 elif (last_comment and re.match(u'\\s*#+\\s*\\w+', line)):
  split_lines = textwrap.wrap(line.lstrip(u'  DCTB #'), initial_indent=indentation, subsequent_indent=indentation, width=max_line_length, break_long_words=False, break_on_hyphens=False)
  return (u'\n'.join(split_lines) + u'\n')
 else:
  return (line + u'\n')

def shorten_comment ( line , max_line_length , last_comment = False ) : assert ( len ( line ) > max_line_length ) line = line . rstrip ( ) indentation = ( _get_indentation ( line ) + u'# ' ) max_line_length = min ( max_line_length , ( len ( indentation ) + 72 ) ) MIN_CHARACTER_REPEAT = 5 if ( ( ( len ( line ) - len ( line . rstrip ( line [ ( - 1 ) ] ) ) ) >= MIN_CHARACTER_REPEAT ) and ( not line [ ( - 1 ) ] . isalnum ( ) ) ) : return ( line [ : max_line_length ] + u'\n' ) elif ( last_comment and re . match ( u'\\s*#+\\s*\\w+' , line ) ) : split_lines = textwrap . wrap ( line . lstrip ( u'  DCTB #' ) , initial_indent = indentation , subsequent_indent = indentation , width = max_line_length , break_long_words = False , break_on_hyphens = False ) return ( u'\n' . join ( split_lines ) + u'\n' ) else : return ( line + u'\n' )
return trimmed or split long comment line .