#NEWLINE# def parse_cfgfile( self , filename ) : #NEWLINE# #INDENT# ' Parse the configuration file and yield pairs of\n            (name, contents) for each node.\n        ' #NEWLINE# with open ( filename , 'r' ) as f : #NEWLINE# #INDENT# for line in f : #NEWLINE# #INDENT# line = line . strip ( ) #NEWLINE# if ( ( not lbracket_i ) or line . startswith ( '#' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# colon_i = line . find ( ':' ) #NEWLINE# lbracket_i = line . find ( '[' ) #NEWLINE# rbracket_i = line . find ( ']' ) #NEWLINE# if ( ( colon_i < 1 ) or ( lbracket_i <= colon_i ) or ( rbracket_i <= lbracket_i ) ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'Invalid line in %s:\n%s\n' % ( filename , line ) ) ) #NEWLINE# #UNINDENT# name = line [ : colon_i ] #NEWLINE# val = line [ ( lbracket_i + 1 ) : rbracket_i ] #NEWLINE# vallist = ( [ v . strip ( ) for v in val . split ( ',' ) ] if val else [ ] ) #NEWLINE# ( yield ( name , vallist ) )