def GetFormatString(event_object):
  """Return back a format string that can be used for a given event object."""
  # Assign a default value to font align length.
  align_length = 15

  # Go through the attributes and see if there is an attribute
  # value that is longer than the default font align length, and adjust
  # it accordingly if found.
  if hasattr(event_object, 'regvalue'):
    attributes = event_object.regvalue.keys()
  else:
    attributes = event_object.GetAttributes().difference(
        event_object.COMPARE_EXCLUDE)

  for attribute in attributes:
    attribute_len = len(attribute)
    if attribute_len > align_length and attribute_len < 30:
      align_length = len(attribute)

  # Create the format string that will be used, using variable length
  # font align length (calculated in the prior step).
  return u'{{0:>{0:d}s}} : {{1!s}}'.format(align_length)