Apply a preset to the hub. If there was a previously active preset, discard it.

        Preset can be either the string name of a preset or a PluginPreset instance.
16598
def use_plugin_preset(self, preset):
        
        if isinstance(preset, str):
            try:
                preset = self._presets[preset]
            except (AttributeError, KeyError):
                raise AngrNoPluginError("There is no preset named %s" % preset)

        elif not isinstance(preset, PluginPreset):
            raise ValueError("Argument must be an instance of PluginPreset: %s" % preset)

        if self._active_preset:
            l.warning("Overriding active preset %s with %s", self._active_preset, preset)
            self.discard_plugin_preset()

        preset.activate(self)
        self._active_preset = preset
1081241
public void deletePreset(String presetName) {
        DeletePresetRequest request = new DeletePresetRequest();
        request.setPresetName(presetName);
        deletePreset(request);
    }
256034
public function savePreset() {
		$key = esc_html($_POST['key']);
		if(empty($key)) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}

		$presets = get_option('ilab-imgix-presets');
		if(!isset($presets[$key])) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}

		$name = $presets[$key]['title'];
		$settings = $_POST['settings'];
		$size = (isset($_POST['size'])) ? esc_html($_POST['size']) : null;
		$makeDefault = (isset($_POST['make_default'])) ? ($_POST['make_default'] == 1) : false;

		$this->doUpdatePresets($key, $name, $settings, $size, $makeDefault);
	}
532595
function includesPresetName(preset) {
	return _.isString(preset) ||
		_.isArray(preset) && _.isString(_.head(preset));
}
1360243
public function deletePreset() {
		$key = esc_html($_POST['key']);
		if(empty($key)) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}


		$presets = get_option('ilab-imgix-presets');
		if($presets) {
			unset($presets[$key]);
			update_option('ilab-imgix-presets', $presets);
		}

		$sizePresets = get_option('ilab-imgix-size-presets');
		if(!$sizePresets) {
			$sizePresets = [];
		}

		foreach($sizePresets as $size => $preset) {
			if($preset == $key) {
				unset($sizePresets[$size]);
				break;
			}
		}

		update_option('ilab-imgix-size-presets', $sizePresets);

		return $this->displayEditUI(1);
	}
904817
public function validatePresets()
    {
        $this->presets_data = array();
        if (!empty($this->assets_db)) {
            foreach ($this->assets_db as $package_name=>$package_data) {
                if (!empty($package_data['assets_presets'])) {
                    foreach ($package_data['assets_presets'] as $preset_name=>$preset_data) {
                        if (array_key_exists($preset_name, $this->presets_data) && ($this->conflict_flag & self::PRESETS_CONFLICT)) {
                            throw new \Exception(
                                sprintf('Presets conflict: duplicate entry named "%s"!', $preset_name)
                            );
                        } else {
                            $this->presets_data[$preset_name] = array(
                                'data'=>$preset_data,
                                'package'=>$package_name
                            );
                        }
                    }
                }
            }
        }
    }
384882
def deactivate(name):
    
    if name in plugins:
        plugins[name].deactivate()
    else:
        raise Exception("plugin {} not found".format(name))
528574
function _handleConfigReset() {
    storage.removeDataByKey(savedConfigKey);

    let initString = getCurrentConfig();

    configEditor.setValue(prettifyInitString(initString));
}
737265
@PostConstruct
	public void preprocess() {
		// FIXME: what should this be?
		setProp(this.serviceId, DeploymentContextBasedVipAddresses.key(), this.serviceId);
		setProp(this.serviceId, EnableZoneAffinity.key(), "true");
	}
665131
def clear(self):
        
        if self._customFormat:
            self._customFormat.clear()
        else:
            super(XSettings, self).clear()
130525
def activate(name):
    
    if name in plugins:
        plugins[name].activate()
    else:
        raise Exception("plugin {} not found".format(name))
458221
public static function removeAllSettingsForPlugin($pluginName)
    {
        try {
            $table = Common::prefixTable('plugin_setting');
            Db::get()->query(sprintf('DELETE FROM %s WHERE plugin_name = ?', $table), array($pluginName));
        } catch (Exception $e) {
            if ($e->getCode() != 42) {
                // ignore table not found error, which might occur when updating from an older version of Piwik
                throw $e;
            }
        }
    }
857778
def remove_preset(preset):
    

    preset_dir = os.path.join(presets_dir(), preset)

    try:
        shutil.rmtree(preset_dir)
    except IOError:
        lib.echo("\"%s\" did not exist" % preset)
58332
public function withPreset(PresetInterface $preset)
	{
		$self = clone $this;
		$self->setOptions($preset->toArray());
		
		return $self;
	}
1278243
def release_plugin(self, name):
        
        plugin = self._active_plugins[name]
        if id(plugin) in self._provided_by_preset:
            self._provided_by_preset.remove(id(plugin))

        del self._active_plugins[name]
        delattr(self, name)
1269406
def apply_to(self,
                 db: Union[BaseDB, ABC_Mutable_Mapping],
                 apply_deletes: bool = True) -> None:
        
        for key, value in self._changes.items():
            if value is DELETED:
                if apply_deletes:
                    try:
                        del db[key]
                    except KeyError:
                        pass
                else:
                    pass
            else:
                db[key] = value
926404
def initialize_plugin(self):
        
        if not self.patterns:
            self.patterns = [
                re.compile(pattern_string)
                for pattern_string in self.PRERELEASE_PATTERNS
            ]
            logger.info(f"Initialized prerelease plugin with {self.patterns}")