#NEWLINE# def _configure( self , config_filename ) : #NEWLINE# #INDENT# ' Configure manager instance. ' #NEWLINE# self . _logger . debug ( 'Configuring from %r' , config_filename ) #NEWLINE# with open ( config_filename , 'r' ) as inp : #NEWLINE# #INDENT# cfg = ConfigParser . ConfigParser ( ) #NEWLINE# cfg . readfp ( inp ) #NEWLINE# for name in cfg . sections ( ) : #NEWLINE# #INDENT# self . _logger . debug ( '  name: %s' , name ) #NEWLINE# for allocator in self . _allocators : #NEWLINE# #INDENT# if ( allocator . name == name ) : #NEWLINE# #INDENT# self . _logger . debug ( '        existing allocator' ) #NEWLINE# allocator . configure ( cfg ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not cfg . has_option ( name , 'classname' ) ) : #NEWLINE# #INDENT# self . _logger . debug ( '        skipping %s' , name ) #NEWLINE# continue #NEWLINE# #UNINDENT# classname = cfg . get ( name , 'classname' ) #NEWLINE# self . _logger . debug ( '    classname: %s' , classname ) #NEWLINE# ( mod_name , _ , cls_name ) = classname . rpartition ( '.' ) #NEWLINE# try : #NEWLINE# #INDENT# __import__ ( mod_name ) #NEWLINE# #UNINDENT# except ImportError as exc : #NEWLINE# #INDENT# raise RuntimeError ( ( "RAM configure %s: can't import %r: %s" % ( name , mod_name , exc ) ) ) #NEWLINE# #UNINDENT# module = sys . modules [ mod_name ] #NEWLINE# if ( not hasattr ( module , cls_name ) ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'RAM configure %s: no class %r in %s' % ( name , cls_name , mod_name ) ) ) #NEWLINE# #UNINDENT# cls = getattr ( module , cls_name ) #NEWLINE# allocator = cls ( name ) #NEWLINE# allocator . configure ( cfg ) #NEWLINE# self . _allocators . append ( allocator )