'Parse the FileUpload passed in argument and return langpack data.
May raise forms.ValidationError()'

def parse(self, upload):

    output = super(LanguagePackParser, self).parse(upload)
    data = self.get_json_data(upload)
    if (data.get('role') != 'langpack'):
        raise forms.ValidationError(_(u'Your    language    pack    should    contain    "role":    "langpack".'))
    languages_provided = data.get('languages-provided', {}).keys()
    if (len(languages_provided) < 1):
        raise forms.ValidationError(_(u'Your    language    pack    must    contain    one    language    in    `languages-provided`    object.'))
    if (len(languages_provided) > 1):
        raise forms.ValidationError(_(u'Your    language    pack    contains    too    many    languages.    Only    one    language    per    pack    is    supported.'))
    languages_target = data.get('languages-target', {}).values()
    if (len(languages_target) < 1):
        raise forms.ValidationError(_(u'Your    language    pack    must    contain    one    language    in    `languages-target`    object.'))
    if (len(languages_target) > 1):
        raise forms.ValidationError(_(u'Your    language    pack    contains    too    many    targets.    Only    one    target    per    pack    is    supported.'))
    version = data.get('version')
    if (version is None):
        raise forms.ValidationError(_(u'Your    language    pack    should    contain    a    version.'))
    if (self.instance and (self.instance.version == version)):
        raise forms.ValidationError(_(u'Your    language    pack    version    must    be    different    to    the    one    you    are    replacing.'))
    output.update({'language': languages_provided[0], 'fxos_version': languages_target[0], 'version': version})
    return output
