def _add_ports_to_platform_node(ports, pn):
     for port_info in ports:
         _require('port_id' in port_info,
                  "_add_ports_to_platform_node(): 'port_id' not in port_info")
         port_id = port_info['port_id']
         port = PortNode(port_id)
         for instrument_id in port_info.get('instrument_ids', []):
             port.add_instrument_id(instrument_id)
         pn.add_port(port)
 def build_and_add_ports_to_node(ports, pn):
     for port_info in ports:
         _require('port_id' in port_info)
         port_id = port_info['port_id']
         port = PortNode(port_id)
         if 'instruments' in port_info:
             for instrument in port_info['instruments']:
                 instrument_id = instrument['instrument_id']
                 _require(not instrument_id in port.instrument_ids,
                          'port_id=%r: duplicate instrument_id=%r' % (
                          port_id, instrument_id))
                 port.add_instrument_id(instrument_id)
         pn.add_port(port)