def _channel_id_to_PIL(channel_id, color_mode):
    if ChannelID.is_known(channel_id):
        if channel_id == ChannelID.TRANSPARENCY_MASK:
            return 'A'
        warnings.warn("Channel %s (%s) is not handled" % (channel_id, ChannelID.name_of(channel_id)))
        return None

    try:
        assert channel_id >= 0
        if color_mode == ColorMode.RGB:
            return 'RGB'[channel_id]
        elif color_mode == ColorMode.CMYK:
            return 'CMYK'[channel_id]
        elif color_mode == ColorMode.GRAYSCALE:
            return 'L'[channel_id]

    except __HOLE__:
        # spot channel
        warnings.warn("Spot channel %s is not handled" % channel_id)
        return None
dataset/ETHPy150Open psd-tools/psd-tools/src/psd_tools/user_api/pil_support.py/_channel_id_to_PIL