def _get_rar_version(xfile):
 with XFile(xfile) as fd:
  buf = fd.read(len(RAR5_ID))
 if buf.startswith(RAR_ID):
  return 3
 elif buf.startswith(RAR5_ID):
  return 5
 return 0

def _get_rar_version ( xfile ) : with XFile ( xfile ) as fd : buf = fd . read ( len ( RAR5_ID ) ) if buf . startswith ( RAR_ID ) : return 3 elif buf . startswith ( RAR5_ID ) : return 5 return 0
check quickly whether file is rar archive .