A board with no ports is allowed.

        In the logfile, ports must be sorted
        - ascending by tile identifier (primary)
        - alphabetical by edge direction (secondary)

        :param ports: list of catan.board.Port objects
489466
def _log_board_ports(self, ports):
        
        ports = sorted(ports, key=lambda port: (port.tile_id, port.direction))
        self._logln('ports: {0}'.format(' '.join('{}({} {})'.format(p.type.value, p.tile_id, p.direction)
                                                for p in ports)))
557645
def pick_contiguous_unused_ports(
    num_ports,
    retry_interval_secs=3,
    retry_attempts=5):
  """"""
  for _ in range(retry_attempts):
    start_port = portpicker.pick_unused_port()
    if start_port is not None:
      ports = [start_port + p for p in range(num_ports)]
      if all(portpicker.is_port_free(p) for p in ports):
        return ports
      else:
        return_ports(ports)

    time.sleep(retry_interval_secs)

  raise RuntimeError("Unable to obtain %d contiguous unused ports." % num_ports)
1118718
def p_ports(self, p):
        ''
        wid = None
        port = Port(name=p[3], width=wid, type=None, lineno=p.lineno(1))
        p[0] = p[1] + (port,)
        p.set_lineno(0, p.lineno(1))
136079
def _pad_former_ports(self, port_handler):
        
        if not port_handler.need_padding():
            return
        for port_idx in range(1, port_handler.port_idx):
            pad_handler = port_handler.__class__(
                port_handler.slot_type,
                port_handler.card_type,
                port_handler.slot_idx,
                port_handler.card_idx,
                port_idx)
            if not self._find_port(pad_handler):
                self._add_port(pad_handler,
                               pad_handler.create_lan_port())
660843
def del_bridge_port(name, port):
    '''  '''
    log('Deleting port {} from bridge {}'.format(port, name))
    subprocess.check_call(["ovs-vsctl", "--", "--if-exists", "del-port",
                           name, port])
    subprocess.check_call(["ip", "link", "set", port, "down"])
    subprocess.check_call(["ip", "link", "set", port, "promisc", "off"])
1290578
def exclude_tcp_service_discovery_ports=(ports)
      service_ports = REXML::XPath.first(@xml, 'ScanTemplate/ServiceDiscovery/ExcludedTCPPortScan')
      REXML::XPath.first(service_ports, './portList').text = ports.join(',')
    end
740912
def ports_mapping(self, ports):
        
        if ports != self._ports:
            if len(self._mappings) > 0:
                raise NodeError("Can't modify a hub already connected.")

            port_number = 0
            for port in ports:
                port["name"] = "Ethernet{}".format(port_number)
                port["port_number"] = port_number
                port_number += 1

            self._ports = ports
1345773
def pick_port(self):
        """"""
        ports = set(range(self.min_port, self.min_port + self.port_range))
        return port_for.select_random(ports)
1343755
def all_ports(self):
        
        from mbuild.port import Port
        return [successor for successor in self.successors()
                if isinstance(successor, Port)]
1326438
def _addPort(n: LNode, lp: LPort, intf: Interface,
             reverseDirection=False):
    
    origin = originObjOfPort(intf)
    d = intf._direction
    d = PortTypeFromDir(d)

    if reverseDirection:
        d = PortType.opposite(d)

    new_lp = LPort(lp, d, lp.side, name=intf._name)
    new_lp.originObj = origin
    if intf._interfaces:
        for child_intf in intf._interfaces:
            _addPort(n, new_lp, child_intf,
                     reverseDirection=reverseDirection)

    lp.children.append(new_lp)
    new_lp.parent = lp
    if n._node2lnode is not None:
        n._node2lnode[origin] = new_lp

    return new_lp
348868
def port(self, name):
        
        for p in self.ports:
            if p.name == name:
                return p
361559
public static void configurePorts(ServerBuilder server, List<Port> ports) {
        requireNonNull(server, "server");
        requireNonNull(ports, "ports");
        ports.forEach(p -> {
            final String ip = p.getIp();
            final String iface = p.getIface();
            final int port = p.getPort();
            final List<SessionProtocol> protocols = p.getProtocols();

            if (ip == null) {
                if (iface == null) {
                    server.port(new ServerPort(port, protocols));
                } else {
                    try {
                        final Enumeration<InetAddress> e = NetworkInterface.getByName(iface).getInetAddresses();
                        while (e.hasMoreElements()) {
                            server.port(new ServerPort(new InetSocketAddress(e.nextElement(), port),
                                                       protocols));
                        }
                    } catch (SocketException e) {
                        throw new IllegalStateException("Failed to find an iface: " + iface, e);
                    }
                }
            } else if (iface == null) {
                if (NetUtil.isValidIpV4Address(ip) || NetUtil.isValidIpV6Address(ip)) {
                    final byte[] bytes = NetUtil.createByteArrayFromIpAddressString(ip);
                    try {
                        server.port(new ServerPort(new InetSocketAddress(
                                InetAddress.getByAddress(bytes), port), protocols));
                    } catch (UnknownHostException e) {
                        // Should never happen.
                        throw new Error(e);
                    }
                } else {
                    throw new IllegalStateException("invalid IP address: " + ip);
                }
            } else {
                throw new IllegalStateException("A port cannot have both IP and iface: " + p);
            }
        });
    }
698225
def accepts_port(self, port):
        

        if self.rejected_ports is None and self.accepted_ports is None:
            raise RuntimeError("policy hasn't been set yet")

        if self.rejected_ports:
            for x in self.rejected_ports:
                if port == x:
                    return False
            return True

        for x in self.accepted_ports:
            if port == x:
                return True
        return False
1138345
public List<Integer> bind(Integer... ports) {
        String boundPorts = sendRequest(request().withMethod("PUT").withPath(calculatePath("bind")).withBody(portBindingSerializer.serialize(portBinding(ports)), StandardCharsets.UTF_8)).getBodyAsString();
        return portBindingSerializer.deserialize(boundPorts).getPorts();
    }
963007
def _port_not_in_use():
    """"""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    port = 0
    s.bind(('', port))
    _, port = s.getsockname()
    return port
646096
def filter_inactive_ports(query):
    
    port_model = models_v2.Port
    query = (query
             .filter(port_model.status == n_const.PORT_STATUS_ACTIVE))
    return query
1086963
function (ports) {
	
	var port = ports[0];

	var list = '';
	for (var i=0; i < ports.length; i++) {
		list += (ports[i] + ', ');
		delete l_ports[ports[i]];
	}

	LOG.warn('release ports: ' + list, 'SR.Monitor');
	
	// remove all other ports associated with this port
	for (var i in l_ports) {
		if (l_ports[i] === port) {
			LOG.warn('release port: ' + i, 'SR.Monitor');
			delete l_ports[i];
		}
	}
}