#NEWLINE# def _parse_comments( s ) : #NEWLINE# #INDENT# " Parses vim's comments option to extract comment format " #NEWLINE# i = iter ( s . split ( ',' ) ) #NEWLINE# rv = [ ] #NEWLINE# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# ( flags , text ) = next ( i ) . split ( ':' , 1 ) #NEWLINE# if ( len ( flags ) == 0 ) : #NEWLINE# #INDENT# rv . append ( ( text , text , text , '' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 's' in flags ) and ( 'O' not in flags ) ) : #NEWLINE# #INDENT# ctriple = [ 'TRIPLE' ] #NEWLINE# indent = '' #NEWLINE# if ( flags [ ( - 1 ) ] in string . digits ) : #NEWLINE# #INDENT# indent = ( ' ' * int ( flags [ ( - 1 ) ] ) ) #NEWLINE# #UNINDENT# ctriple . append ( text ) #NEWLINE# ( flags , text ) = next ( i ) . split ( ':' , 1 ) #NEWLINE# assert ( flags [ 0 ] == 'm' ) #NEWLINE# ctriple . append ( indent ) #NEWLINE# ( flags , text ) = next ( i ) . split ( ':' , 1 ) #NEWLINE# assert ( flags [ 0 ] == 'e' ) #NEWLINE# ctriple . append ( text ) #NEWLINE# ctriple . append ( indent ) #NEWLINE# rv . append ( ctriple ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'b' in flags ) : #NEWLINE# #INDENT# if ( len ( text ) == 1 ) : #NEWLINE# #INDENT# rv . insert ( 0 , ( 'SINGLE_CHAR' , text , text , text , '' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# return rv