#NEWLINE# def parseDefBlock( lines , type , capitalizeKeys = True ) : #NEWLINE# #INDENT# vals = OrderedDict ( ) #NEWLINE# lastKey = None #NEWLINE# for line in lines : #NEWLINE# #INDENT# match = re . match ( '\\s*([^:]+):\\s*(\\S.*)' , line ) #NEWLINE# if ( match is None ) : #NEWLINE# #INDENT# if ( ( lastKey is not None ) and ( ( line . strip ( ) == '' ) or re . match ( '\\s+' , line ) ) ) : #NEWLINE# #INDENT# key = lastKey #NEWLINE# val = line . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# die ( "Incorrectly formatted {2} line for '{0}':\n{1}" , vals . get ( 'Name' , '???' ) , line , type ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# key = match . group ( 1 ) . strip ( ) #NEWLINE# if vals : #NEWLINE# #INDENT# key = key . capitalize ( ) #NEWLINE# #UNINDENT# lastKey = key #NEWLINE# val = match . group ( 2 ) . strip ( ) #NEWLINE# #UNINDENT# if ( key in vals ) : #NEWLINE# #INDENT# vals [ key ] += ( '\n' + val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# vals [ key ] = val #NEWLINE# #UNINDENT# #UNINDENT# return vals