Sets an individual setting to the specified value. If no filename has been specified up to this point, then a default filename will be used. After value has been modified, the settings file is written to disk. Note that this call is not value for a config file norma
(self, key, value)
| 22813 | self.save() |
| 22814 | |
| 22815 | def set(self, key, value): |
| 22816 | """ |
| 22817 | Sets an individual setting to the specified value. If no filename has been specified up to this point, |
| 22818 | then a default filename will be used. |
| 22819 | After value has been modified, the settings file is written to disk. |
| 22820 | Note that this call is not value for a config file normally. If it is, then the key is assumed to be the |
| 22821 | Section key and the value written will be the default value. |
| 22822 | :param key: Setting to be saved. Can be any valid dictionary key type |
| 22823 | :type key: (Any) |
| 22824 | :param value: Value to save as the setting's value. Can be anything |
| 22825 | :type value: (Any) |
| 22826 | :return: value that key was set to |
| 22827 | :rtype: (Any) |
| 22828 | """ |
| 22829 | |
| 22830 | if self.full_filename is None: |
| 22831 | self.set_location() |
| 22832 | # if not autosaving, then don't read the file or else will lose changes |
| 22833 | if not self.use_config_file: |
| 22834 | if self.autosave or self.dict == {}: |
| 22835 | self.read() |
| 22836 | self.dict[key] = value |
| 22837 | else: |
| 22838 | self.section_class_dict[key].set(value, self.default_value) |
| 22839 | |
| 22840 | if self.autosave: |
| 22841 | self.save() |
| 22842 | return value |
| 22843 | |
| 22844 | def get(self, key, default=None): |
| 22845 | """ |
no test coverage detected