def join_translated(translated_parts, os_sep_class, subentries_match):
    """Join translated glob pattern parts.
    This is different from a simple join, as care need to be taken
    to allow ** to match ZERO or more directories.
    """
    res = ''
    for part in translated_parts[:-1]:
        if part == double_start_re:
            # drop separator, since it is optional
            # (** matches ZERO or more dirs)
            res += part
        else:
            res += part + os_sep_class

    if translated_parts[-1] == double_start_re:
        # Final part is **
        # Should not match directory:
        res += '.+'
        # Follow stdlib/git convention of matching all sub files/directories:
        res += '({os_sep_class}?.*)?'.format(os_sep_class=os_sep_class)
    elif subentries_match:
        # Should match directory, but might also match sub entries:
        res += translated_parts[-1]
        res += '({os_sep_class}?.*)?'.format(os_sep_class=os_sep_class)
    else:
        res += translated_parts[-1]
        # Allow trailing slashes
        # Note: This indicates that the last part whould be a directory, but
        # we explictly say that we don't consult the filesystem, so there is
        # no way for us to know.
        res += '{os_sep_class}?'.format(os_sep_class=os_sep_class)
    return res
Join translated glob pattern parts.
    This is different from a simple join, as care need to be taken
    to allow ** to match ZERO or more directories.
    
src/globmatch/translation.py