def check_returncode(p, out):
 code = p.returncode
 if (code == 0):
  return
 errmap = [None, RarWarning, RarFatalError, RarCRCError, RarLockedArchiveError, RarWriteError, RarOpenError, RarUserError, RarMemoryError, RarCreateError, RarNoFilesError]
 if (UNRAR_TOOL == ALT_TOOL):
  errmap = [None]
 if ((code > 0) and (code < len(errmap))):
  exc = errmap[code]
 elif (code == 255):
  exc = RarUserBreak
 elif (code < 0):
  exc = RarSignalExit
 else:
  exc = RarUnknownError
 if out:
  msg = ('%s [%d]: %s' % (exc.__doc__, p.returncode, out))
 else:
  msg = ('%s [%d]' % (exc.__doc__, p.returncode))
 raise exc(msg)

def check_returncode ( p , out ) : code = p . returncode if ( code == 0 ) : return errmap = [ None , RarWarning , RarFatalError , RarCRCError , RarLockedArchiveError , RarWriteError , RarOpenError , RarUserError , RarMemoryError , RarCreateError , RarNoFilesError ] if ( UNRAR_TOOL == ALT_TOOL ) : errmap = [ None ] if ( ( code > 0 ) and ( code < len ( errmap ) ) ) : exc = errmap [ code ] elif ( code == 255 ) : exc = RarUserBreak elif ( code < 0 ) : exc = RarSignalExit else : exc = RarUnknownError if out : msg = ( '%s [%d]: %s' % ( exc . __doc__ , p . returncode , out ) ) else : msg = ( '%s [%d]' % ( exc . __doc__ , p . returncode ) ) raise exc ( msg )
raise exception according to unrar exit code .