def check_hash(path, file_hash):
 path = os.path.expanduser(path)
 hash_parts = file_hash.split(':', 1)
 if (len(hash_parts) != 2):
  hash_parts = file_hash.split('=', 1)
  if (len(hash_parts) != 2):
   raise ValueError("Bad hash format: '{0}'".format(file_hash))
 (hash_form, hash_value) = hash_parts
 return (get_hash(path, hash_form) == hash_value)

def check_hash ( path , file_hash ) : path = os . path . expanduser ( path ) hash_parts = file_hash . split ( ':' , 1 ) if ( len ( hash_parts ) != 2 ) : hash_parts = file_hash . split ( '=' , 1 ) if ( len ( hash_parts ) != 2 ) : raise ValueError ( "Bad hash format: '{0}'" . format ( file_hash ) ) ( hash_form , hash_value ) = hash_parts return ( get_hash ( path , hash_form ) == hash_value )
returns true if hash does not match the previous one .