def pack_sources(sources, normalize=True):
 if (normalize and ('pkg.normalize_name' in __salt__)):
  _normalize_name = __salt__['pkg.normalize_name']
 else:
  _normalize_name = (lambda pkgname: pkgname)
 if isinstance(sources, six.string_types):
  try:
   sources = yaml.safe_load(sources)
  except yaml.parser.ParserError as err:
   log.error(err)
   return {}
 ret = {}
 for source in sources:
  if ((not isinstance(source, dict)) or (len(source) != 1)):
   log.error('Invalid input: {0}'.format(pprint.pformat(sources)))
   log.error('Input must be a list of 1-element dicts')
   return {}
  else:
   key = next(iter(source))
   ret[_normalize_name(key)] = source[key]
 return ret

def pack_sources ( sources , normalize = True ) : if ( normalize and ( 'pkg.normalize_name' in __salt__ ) ) : _normalize_name = __salt__ [ 'pkg.normalize_name' ] else : _normalize_name = ( lambda pkgname : pkgname ) if isinstance ( sources , six . string_types ) : try : sources = yaml . safe_load ( sources ) except yaml . parser . ParserError as err : log . error ( err ) return { } ret = { } for source in sources : if ( ( not isinstance ( source , dict ) ) or ( len ( source ) != 1 ) ) : log . error ( 'Invalid input: {0}' . format ( pprint . pformat ( sources ) ) ) log . error ( 'Input must be a list of 1-element dicts' ) return { } else : key = next ( iter ( source ) ) ret [ _normalize_name ( key ) ] = source [ key ] return ret
accepts list of dicts and packs the key/value pairs into a single dict .