def open_archive(archive_path):
 archive = None
 if (not os.path.exists(archive_path)):
  raise PathError(u"Path doesn't exist")
 if zipfile.is_zipfile(archive_path):
  archive = ZipArchive(archive_path)
  log.debug(u'Successfully opened ZIP: %s', archive_path)
 elif (rarfile and rarfile.is_rarfile(archive_path)):
  archive = RarArchive(archive_path)
  log.debug(u'Successfully opened RAR: %s', archive_path)
 elif (not rarfile):
  log.warning(u'Rarfile module not installed; unable to handle RAR archives.')
 return archive

def open_archive ( archive_path ) : archive = None if ( not os . path . exists ( archive_path ) ) : raise PathError ( u"Path doesn't exist" ) if zipfile . is_zipfile ( archive_path ) : archive = ZipArchive ( archive_path ) log . debug ( u'Successfully opened ZIP: %s' , archive_path ) elif ( rarfile and rarfile . is_rarfile ( archive_path ) ) : archive = RarArchive ( archive_path ) log . debug ( u'Successfully opened RAR: %s' , archive_path ) elif ( not rarfile ) : log . warning ( u'Rarfile module not installed; unable to handle RAR archives.' ) return archive
returns the appropriate archive object .