def parsePortSpec(spec, separator='-'):
    """
    Parses a port specification in two forms into the same form.

    In the first form the specification is just an integer. In this case a
    tuple is returned containing the same integer twice.

    In the second form the specification is two numbers separated by a hyphen
    ('-' by default, specifiable with :param separator:). The two numbers are
    parsed as integers and returned in the same order as a tuple of two
    integers.

    Example:

    .. code-block: python

       parsePortSpec('12345') # -> (12345, 12345)
       parsePortSpec('12345-56789') # -> (12345, 56789)
    """
    x = list(map(lambda x: x.strip(), spec.split(separator)))
    return tuple(map(int, x * (3 - len(x))))
