Fix handling of empty selectors in PathLikeSelector.count_ports().
Add from_index method to BasePortMapper.