Given a dictionary template containing at least most of the relevant information and a dictionary target containing sections, options and values, consolidate target into a new confmanager object and return it.

def parse_template(template, target):
 """Given a dictionary template containing at least most of the relevant information and a dictionary target containing sections, options and values, consolidate target into a new confmanager object and return it."""
 c = ConfManager('')
 for section in template:
  c.add_section(section)
  for option, o in template[section].items():
   try:
    value = type(template[section][option]['value'])(target[section][option])
   except KeyError:
    value = o['value']
   finally:
    if 'value' in o:
     del o['value']
   c.set(section, option, value, **o)
 return c