import optparse


def check_key_value(option, opt, value):
  """Checks value is split in two by a ':', returns the parts in a tuple."""
  result = value.split(':');
  if not len(result) == 2:
    raise optparse.OptionValueError(
        "option %s: invalid value: %s should be of the form '<key>:<value>'"
        % (opt, value))
  return tuple(result)