import re


def _ShortenGutsTicket(o):
  """Shorten a Google GUTS ticket URI.

  Args:
    o: The named tuple from a urllib.parse.urlsplit call.

  Returns:
    A new named tuple that can be passed to urllib.parse.urlunsplit.
  """
  # https://gutsv3.corp.google.com/#ticket/123
  m = re.match(r'^ticket/([0-9]+)', o.fragment)
  if m:
    o = o._replace(path='/%s' % (m.group(1),), fragment='')

  return o._replace(scheme='http', netloc='t')