'Save the current configuration of the core to the profile called
profile_name.
:return: The new profile instance if the profile was successfully saved.
Otherwise raise a BaseFrameworkException.'

def save_current_to_profile(self, profile_name, prof_desc='', prof_path='', self_contained=False):

    new_profile = profile(profile_name, workdir=os.path.dirname(prof_path))
    w3af_plugins = self._w3af_core.plugins
    for plugin_type in w3af_plugins.get_plugin_types():
        enabled_plugins = []
        for plugin_name in w3af_plugins.get_enabled_plugins(plugin_type):
            enabled_plugins.append(plugin_name)
        new_profile.set_enabled_plugins(plugin_type, enabled_plugins)
    for plugin_type in w3af_plugins.get_plugin_types():
        for plugin_name in w3af_plugins.get_enabled_plugins(plugin_type):
            plugin_options = w3af_plugins.get_plugin_options(plugin_type, plugin_name)
            if plugin_options:
                new_profile.set_plugin_options(plugin_type, plugin_name, plugin_options, self_contained=self_contained)
    targets = cf.cf.get('targets')
    if targets:
        new_profile.set_target('    ,    '.join((t.url_string for t in targets)))
    misc_settings = MiscSettings()
    new_profile.set_misc_settings(misc_settings.get_options())
    new_profile.set_http_settings(self._w3af_core.uri_opener.settings.get_options())
    new_profile.set_desc(prof_desc)
    new_profile.set_name(profile_name)
    new_profile.save(profile_name)
    return new_profile
