Fetches profile specific options if applicable

    @see :func:`get_returner_options`

    :return: a options dict

def _fetch_profile_opts(
        cfg, virtualname,
        __salt__,
        _options,
        profile_attr,
        profile_attrs
    ):
    """
    Fetches profile specific options if applicable

    @see :func:`get_returner_options`

    :return: a options dict
    """

    if (not profile_attr) or (profile_attr not in _options):
        return {}

    # Using a profile and it is in _options

    creds = {}
    profile = _options[profile_attr]
    if profile:
        log.info('Using profile %s', profile)

        if 'config.option' in __salt__:
            creds = cfg(profile)
        else:
            creds = cfg.get(profile)

    if not creds:
        return {}

    return dict(
        (
            pattr,
            creds.get('{0}.{1}'.format(virtualname, profile_attrs[pattr]))
        )
        for pattr in profile_attrs
        )