def parse_account(config, auth, account):
  """ Breaks a [account:advertiser@profile] string into parts if supplied.

  This function was created to accomodate supplying advertiser and profile
  information
  as a single token.  It needs to be refactored as this approach is messy.

  Possible variants include:
    * [account:advertiser@profile]
    * [account:advertiser]
    * [account@profile]

  Args:
    * auth: (string) Either user or service.
    * account: (string) A string represeting [account:advertiser@profile]

  Returns:
    * ( network_id, advertiser_ids, profile_id) after parsing the account token.

  """

  network_id = account
  advertiser_ids = None
  profile_id = None

  # if exists, get profile from end
  try:
    network_id, profile_id = network_id.split('@', 1)
  except:
    profile_id = None

  # if exists, get avertiser from end
  try:
    network_id, advertiser_ids = network_id.split(':', 1)
  except:
    pass

  # if network or advertiser, convert to integer
  if network_id is not None:
    network_id = int(network_id)
  if advertiser_ids is not None:
    advertiser_ids = [
        int(advertiser_id.strip())
        for advertiser_id in advertiser_ids.split(',')
    ]

  return network_id, advertiser_ids