import socket


def parsePort(port):
  """
  Converts port in string format to an int

  :param port: a string or integer value
  :returns: an integer port number
  :rtype: int

  """
  result = None
  try:
    result = int(port)
  except ValueError:
    result = socket.getservbyname(port)
  return result