def sfv_check(sfv_path):
 failed = []
 try:
  fp = open(sfv_path, 'r')
 except:
  logging.info('Cannot open SFV file %s', sfv_path)
  failed.append(unicoder(sfv_path))
  return failed
 root = os.path.split(sfv_path)[0]
 for line in fp:
  line = line.strip('\n\r ')
  if (line and (line[0] != ';')):
   x = line.rfind(' ')
   if (x > 0):
    filename = platform_encode(line[:x].strip())
    checksum = line[x:].strip()
    path = os.path.join(root, filename)
    if os.path.exists(path):
     if crc_check(path, checksum):
      logging.debug('File %s passed SFV check', path)
     else:
      logging.info('File %s did not pass SFV check', path)
      failed.append(unicoder(filename))
    else:
     logging.info('File %s missing in SFV check', path)
     failed.append(unicoder(filename))
 fp.close()
 return failed

def sfv_check ( sfv_path ) : failed = [ ] try : fp = open ( sfv_path , 'r' ) except : logging . info ( 'Cannot open SFV file %s' , sfv_path ) failed . append ( unicoder ( sfv_path ) ) return failed root = os . path . split ( sfv_path ) [ 0 ] for line in fp : line = line . strip ( '\n\r ' ) if ( line and ( line [ 0 ] != ';' ) ) : x = line . rfind ( ' ' ) if ( x > 0 ) : filename = platform_encode ( line [ : x ] . strip ( ) ) checksum = line [ x : ] . strip ( ) path = os . path . join ( root , filename ) if os . path . exists ( path ) : if crc_check ( path , checksum ) : logging . debug ( 'File %s passed SFV check' , path ) else : logging . info ( 'File %s did not pass SFV check' , path ) failed . append ( unicoder ( filename ) ) else : logging . info ( 'File %s missing in SFV check' , path ) failed . append ( unicoder ( filename ) ) fp . close ( ) return failed
verify files using sfv file .