def guess_portname(fragment, portlist):
    """
    iterate over all names in portlist and return the first that has fragment
    as a substring of its name
    Raises ValueError if not found
    """
    for port in portlist:
        if fragment in port:
            return port
    raise ValueError(f'Unable to guess port from {fragment!r}')