#NEWLINE# def update_defaults( self , defaults ) : #NEWLINE# #INDENT# 'Updates the given defaults with values from the config files and\n        the environ. Does a little special handling for certain types of\n        options (lists).' #NEWLINE# config = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for section in ( 'global' , self . name ) : #NEWLINE# #INDENT# config . update ( dict ( self . get_config_section ( section ) ) ) #NEWLINE# #UNINDENT# config . update ( dict ( self . get_environ_vars ( ) ) ) #NEWLINE# for ( key , val ) in config . items ( ) : #NEWLINE# #INDENT# key = key . replace ( '_' , '-' ) #NEWLINE# if ( not key . startswith ( '--' ) ) : #NEWLINE# #INDENT# key = ( '--%s' % key ) #NEWLINE# #UNINDENT# option = self . get_option ( key ) #NEWLINE# if ( option is not None ) : #NEWLINE# #INDENT# if ( not val ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( option . action == 'append' ) : #NEWLINE# #INDENT# val = val . split ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# option . nargs = 1 #NEWLINE# #UNINDENT# if ( option . action in ( 'store_true' , 'store_false' , 'count' ) ) : #NEWLINE# #INDENT# val = strtobool ( val ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# val = option . convert_value ( key , val ) #NEWLINE# #UNINDENT# except optparse . OptionValueError : #NEWLINE# #INDENT# e = sys . exc_info ( ) [ 1 ] #NEWLINE# print ( ( 'An error occured during configuration: %s' % e ) ) #NEWLINE# sys . exit ( 3 ) #NEWLINE# #UNINDENT# defaults [ option . dest ] = val #NEWLINE# #UNINDENT# #UNINDENT# return defaults