def GetConfigMockClass(sections=None):
 if (sections is None):
  sections = {}
 missing = object()
 type_infos = []
 values = {}
 raw_values = {}
 default_values = {}
 for (section_name, section) in sections.iteritems():
  for (parameter_name, parameter_data) in section.iteritems():
   name = ('%s.%s' % (section_name, parameter_name))
   descriptor = utils.DataObject(section=section_name, name=name)
   type_infos.append(descriptor)
   if ('value' in parameter_data):
    values[name] = parameter_data['value']
   if ('raw_value' in parameter_data):
    raw_values[name] = parameter_data['raw_value']
   if ('default_value' in parameter_data):
    default_values[name] = parameter_data['default_value']
 def Get(parameter, default=missing):
  try:
   return values[parameter]
  except KeyError:
   if (default is missing):
    return default_values[parameter]
   return default
 def GetRaw(parameter, default=missing):
  try:
   return raw_values[parameter]
  except KeyError:
   if (default is missing):
    return default_values[parameter]
   return default
 return {'Get': Get, 'GetRaw': GetRaw, 'type_infos': type_infos}

def GetConfigMockClass ( sections = None ) : if ( sections is None ) : sections = { } missing = object ( ) type_infos = [ ] values = { } raw_values = { } default_values = { } for ( section_name , section ) in sections . iteritems ( ) : for ( parameter_name , parameter_data ) in section . iteritems ( ) : name = ( '%s.%s' % ( section_name , parameter_name ) ) descriptor = utils . DataObject ( section = section_name , name = name ) type_infos . append ( descriptor ) if ( 'value' in parameter_data ) : values [ name ] = parameter_data [ 'value' ] if ( 'raw_value' in parameter_data ) : raw_values [ name ] = parameter_data [ 'raw_value' ] if ( 'default_value' in parameter_data ) : default_values [ name ] = parameter_data [ 'default_value' ] def Get ( parameter , default = missing ) : try : return values [ parameter ] except KeyError : if ( default is missing ) : return default_values [ parameter ] return default def GetRaw ( parameter , default = missing ) : try : return raw_values [ parameter ] except KeyError : if ( default is missing ) : return default_values [ parameter ] return default return { 'Get' : Get , 'GetRaw' : GetRaw , 'type_infos' : type_infos }
mocks a configuration file for use by the api handler .