def parse_xpi(xpi, addon=None, check=True):
 path = tempfile.mkdtemp()
 try:
  xpi = get_file(xpi)
  extract_xpi(xpi, path)
  xpi_info = Extractor.parse(path)
 except forms.ValidationError:
  raise
 except IOError as e:
  if (len(e.args) < 2):
   (errno, strerror) = (None, e[0])
  else:
   (errno, strerror) = e
  log.error('I/O error({0}): {1}'.format(errno, strerror))
  raise forms.ValidationError(_('Could not parse the manifest file.'))
 except Exception:
  log.error('XPI parse error', exc_info=True)
  raise forms.ValidationError(_('Could not parse the manifest file.'))
 finally:
  rm_local_tmp_dir(path)
 if check:
  return check_xpi_info(xpi_info, addon)
 else:
  return xpi_info

def parse_xpi ( xpi , addon = None , check = True ) : path = tempfile . mkdtemp ( ) try : xpi = get_file ( xpi ) extract_xpi ( xpi , path ) xpi_info = Extractor . parse ( path ) except forms . ValidationError : raise except IOError as e : if ( len ( e . args ) < 2 ) : ( errno , strerror ) = ( None , e [ 0 ] ) else : ( errno , strerror ) = e log . error ( 'I/O error({0}): {1}' . format ( errno , strerror ) ) raise forms . ValidationError ( _ ( 'Could not parse the manifest file.' ) ) except Exception : log . error ( 'XPI parse error' , exc_info = True ) raise forms . ValidationError ( _ ( 'Could not parse the manifest file.' ) ) finally : rm_local_tmp_dir ( path ) if check : return check_xpi_info ( xpi_info , addon ) else : return xpi_info
extract and parse an xpi .