import re


def get_outlet_port_code(outlet):
  """Returns outlet port and code.

  Args:
    outlet: string, outlet ID

  Returns:
    port, code: tuple, port and code
  """

  # Extract port and outlet code

  outlet = outlet.lower()

  outlet_port = ''
  outlet_code = ''

  match = re.search(r'([-\w\d]+)-(eth_[outin]+[\d]+)$', outlet)
  if match:
    outlet_code = match.groups()[0]
    outlet_port = match.groups()[1]
  else:
    match = re.search(r'([-\w\d]+)(_[outin]+[\d]+)$', outlet)
    if match:
      outlet_code = match.groups()[0]
      outlet_port = 'eth' + match.groups()[1].upper()

  outlet_code = outlet_code.upper()

  # Make sure NET is in outlet_code
  if 'NET' not in outlet_code:
    outlet_code = outlet_code.replace('-NO-', '-NET-NO-')
    outlet_code = outlet_code.replace('-ASW-', '-NET-ASW-')
    outlet_code = outlet_code.replace('-PP-', '-NET-PP-')

  return outlet_port, outlet_code