def error_summary(error_dict):
 def prettify(field_name):
  field_name = re.sub('(?<!\\w)[Uu]rl(?!\\w)', 'URL', field_name.replace('_', ' ').capitalize())
  return _(field_name.replace('_', ' '))
 summary = {}
 for (key, error) in error_dict.iteritems():
  if (key == 'resources'):
   summary[_('Resources')] = _('Package resource(s) invalid')
  elif (key == 'extras'):
   summary[_('Extras')] = _('Missing Value')
  elif (key == 'extras_validation'):
   summary[_('Extras')] = error[0]
  else:
   summary[_(prettify(key))] = error[0]
 return summary

def error_summary ( error_dict ) : def prettify ( field_name ) : field_name = re . sub ( '(?<!\\w)[Uu]rl(?!\\w)' , 'URL' , field_name . replace ( '_' , ' ' ) . capitalize ( ) ) return _ ( field_name . replace ( '_' , ' ' ) ) summary = { } for ( key , error ) in error_dict . iteritems ( ) : if ( key == 'resources' ) : summary [ _ ( 'Resources' ) ] = _ ( 'Package resource(s) invalid' ) elif ( key == 'extras' ) : summary [ _ ( 'Extras' ) ] = _ ( 'Missing Value' ) elif ( key == 'extras_validation' ) : summary [ _ ( 'Extras' ) ] = error [ 0 ] else : summary [ _ ( prettify ( key ) ) ] = error [ 0 ] return summary
do some i18n stuff on the error_dict keys .