コード例 #1
0
    def setConfig(self, option, value):
        """ Sets a config value for this account instance. Modifying the global values is not allowed. """
        if option not in self.config_data:
            return

        value = from_string(value, self.config_data[option].input.type)
        # given value is the default value and does not need to be saved at all
        if value == self.config_data[option].input.default_value:
            if option in self.options:
                del self.options[option]
        else:
            self.options[option] = from_string(value, self.config_data[option].input.type)
コード例 #2
0
    def set(self, section, option, value, sync=True):
        """Set value"""

        data = self.config[section].config[option]
        value = convert.from_string(value, data.input.type)
        old_value = self.get(section, option)

        # only save when different values
        if value != old_value:
            if section not in self.values:
                self.values[section] = {}
            self.values[section][option] = value
            if sync:
                self.save()
            return True

        return False
コード例 #3
0
    def set(self, section, option, value, sync=True, user=None):
        """
        Set config value.
        """
        changed = False
        if section in self.parser and user is None:
            changed = self.parser.set(section, option, value, sync)
        else:
            data = self.config[section].config[option]
            value = from_string(value, data.input.type)
            old_value = self.get(section, option)

            # Values will always be saved to db, sync is ignored
            if value != old_value:
                changed = True
                self.values[user, section][option] = value
                if sync:
                    self.save_values(user, section)

        if changed:
            self.pyload.evm.fire("config:changed", section, option, value)
        return changed
コード例 #4
0
ファイル: config.py プロジェクト: vuolter/pyload
    def set(self, section, option, value, sync=True, user=None):
        """
        Set config value.
        """
        changed = False
        if section in self.parser and user is None:
            changed = self.parser.set(section, option, value, sync)
        else:
            data = self.config[section].config[option]
            value = from_string(value, data.input.type)
            old_value = self.get(section, option)

            # Values will always be saved to db, sync is ignored
            if value != old_value:
                changed = True
                self.values[user, section][option] = value
                if sync:
                    self.save_values(user, section)

        if changed:
            self.pyload.evm.fire("config:changed", section, option, value)
        return changed