<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def port(self, port_range: PortRange = PortRange.ALL) -> int: """Generate random port. :param port_range: Range enum object. :return: Port number. :raises NonEnumerableError: if port_range is not in PortRange. :Example: 8080 """

        if port_range and port_range in PortRange:
            return self.random.randint(*port_range.value)
        else:
            raise NonEnumerableError(PortRange)