def _verify_dict_keys(expected_keys, target_dict, strict=True):
 if (not isinstance(target_dict, dict)):
  msg = (_("Invalid input. '%(target_dict)s' must be a dictionary with keys: %(expected_keys)s") % dict(target_dict=target_dict, expected_keys=expected_keys))
  return msg
 expected_keys = set(expected_keys)
 provided_keys = set(target_dict.keys())
 predicate = (expected_keys.__eq__ if strict else expected_keys.issubset)
 if (not predicate(provided_keys)):
  msg = (_("Validation of dictionary's keys failed.Expected keys: %(expected_keys)s Provided keys: %(provided_keys)s") % locals())
  return msg

def _verify_dict_keys ( expected_keys , target_dict , strict = True ) : if ( not isinstance ( target_dict , dict ) ) : msg = ( _ ( "Invalid input. '%(target_dict)s' must be a dictionary with keys: %(expected_keys)s" ) % dict ( target_dict = target_dict , expected_keys = expected_keys ) ) return msg expected_keys = set ( expected_keys ) provided_keys = set ( target_dict . keys ( ) ) predicate = ( expected_keys . __eq__ if strict else expected_keys . issubset ) if ( not predicate ( provided_keys ) ) : msg = ( _ ( "Validation of dictionary's keys failed.Expected keys: %(expected_keys)s Provided keys: %(provided_keys)s" ) % locals ( ) ) return msg
allows to verify keys in a dictionary .