def format_dimension(key, value, expiration_secs):
  """Formats a dimension to a string. Opposite of parse_dimension."""
  if expiration_secs:
    return '%d:%s:%s' % (expiration_secs, key, value)
  return '%s:%s' % (key, value)