#NEWLINE# def _read( self , fp , fpname ) : #NEWLINE# #INDENT# cursect = None #NEWLINE# optname = None #NEWLINE# lineno = 0 #NEWLINE# e = None #NEWLINE# while True : #NEWLINE# #INDENT# line = fp . readline ( ) #NEWLINE# if ( not line ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# lineno += 1 #NEWLINE# if ( ( line . strip ( ) == '' ) or ( line [ 0 ] in '#;' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( line . split ( None , 1 ) [ 0 ] . lower ( ) == 'rem' ) and ( line [ 0 ] in 'rR' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( line [ 0 ] . isspace ( ) and ( cursect is not None ) and optname ) : #NEWLINE# #INDENT# value = line . strip ( ) #NEWLINE# if value : #NEWLINE# #INDENT# cursect [ optname ] . append ( value ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# mo = self . SECTCRE . match ( line ) #NEWLINE# if mo : #NEWLINE# #INDENT# sectname = mo . group ( 'header' ) #NEWLINE# if ( sectname in self . _sections ) : #NEWLINE# #INDENT# cursect = self . _sections [ sectname ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sectname == DEFAULTSECT ) : #NEWLINE# #INDENT# cursect = self . _defaults #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cursect = self . _dict ( ) #NEWLINE# cursect [ '__name__' ] = sectname #NEWLINE# self . _sections [ sectname ] = cursect #NEWLINE# #UNINDENT# #UNINDENT# optname = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cursect is None ) : #NEWLINE# #INDENT# raise MissingSectionHeaderError ( fpname , lineno , line ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# mo = self . _optcre . match ( line ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# mo = self . OPTCRE . match ( line ) #NEWLINE# #UNINDENT# if mo : #NEWLINE# #INDENT# ( optname , vi , optval ) = mo . group ( 'option' , 'vi' , 'value' ) #NEWLINE# self . optionxform = text_type #NEWLINE# optname = self . optionxform ( optname . rstrip ( ) ) #NEWLINE# if ( optname in cursect ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( optval is not None ) : #NEWLINE# #INDENT# if ( ( vi in ( '=' , ':' ) ) and ( ';' in optval ) ) : #NEWLINE# #INDENT# pos = optval . find ( ';' ) #NEWLINE# if ( ( pos != ( - 1 ) ) and optval [ ( pos - 1 ) ] . isspace ( ) ) : #NEWLINE# #INDENT# optval = optval [ : pos ] #NEWLINE# #UNINDENT# #UNINDENT# optval = optval . strip ( ) #NEWLINE# if ( optval == '""' ) : #NEWLINE# #INDENT# optval = '' #NEWLINE# #UNINDENT# cursect [ optname ] = [ optval ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cursect [ optname ] = optval #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not e ) : #NEWLINE# #INDENT# e = ParsingError ( fpname ) #NEWLINE# #UNINDENT# e . append ( lineno , repr ( line ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if e : #NEWLINE# #INDENT# raise e #NEWLINE# #UNINDENT# all_sections = [ self . _defaults ] #NEWLINE# all_sections . extend ( self . _sections . values ( ) ) #NEWLINE# for options in all_sections : #NEWLINE# #INDENT# for ( name , val ) in options . items ( ) : #NEWLINE# #INDENT# if isinstance ( val , list ) : #NEWLINE# #INDENT# options [ name ] = '\n' . join ( val )