Esempio n. 1
0
    def add_new_preset(self, new_preset: VersionedPreset) -> bool:
        """
        Adds a new custom preset.
        :param: new_preset
        :return True, if there wasn't any preset with that name
        """
        if self._included_preset_with_name(new_preset.name) is not None:
            raise ValueError("A default preset with name '{}' already exists.".format(new_preset.name))

        existed_before = new_preset.name in self.custom_presets
        self.custom_presets[new_preset.name] = new_preset

        path = self._file_name_for_preset(new_preset)
        new_preset.save_to_file(path)
        return not existed_before
Esempio n. 2
0
    def add_new_preset(self, new_preset: VersionedPreset) -> bool:
        """
        Adds a new custom preset.
        :param: new_preset
        :return True, if there wasn't any preset with that name
        """
        assert new_preset.uuid not in self.included_presets
        existed_before = new_preset.uuid in self.custom_presets
        self.custom_presets[new_preset.uuid] = new_preset

        path = self._file_name_for_preset(new_preset)
        new_preset.save_to_file(path)
        _commit(f"Update preset '{new_preset.name}'", path, self._data_dir.parent, False)

        return not existed_before