Saves the current settings dictionary. If a filename or path is specified in the call, then it will override any previously specitfied filename to create a new settings file. The settings dictionary is then saved to the newly defined file. :param filename: The fFilename t
(self, filename=None, path=None)
| 22633 | return self.full_filename |
| 22634 | |
| 22635 | def save(self, filename=None, path=None): |
| 22636 | """ |
| 22637 | Saves the current settings dictionary. If a filename or path is specified in the call, then it will override any |
| 22638 | previously specitfied filename to create a new settings file. The settings dictionary is then saved to the newly defined file. |
| 22639 | |
| 22640 | :param filename: The fFilename to save to. Can specify a path or just the filename. If no filename specified, then the caller's filename will be used. |
| 22641 | :type filename: (str or None) |
| 22642 | :param path: The (optional) path to use to save the file. |
| 22643 | :type path: (str or None) |
| 22644 | :return: The full path and filename used to save the settings |
| 22645 | :rtype: (str) |
| 22646 | """ |
| 22647 | if filename is not None or path is not None: |
| 22648 | self.set_location(filename=filename, path=path) |
| 22649 | try: |
| 22650 | if not os.path.exists(self.path): |
| 22651 | os.makedirs(self.path) |
| 22652 | with open(self.full_filename, 'w') as f: |
| 22653 | if not self.use_config_file: |
| 22654 | json.dump(self.dict, f) |
| 22655 | else: |
| 22656 | self.config.write(f) |
| 22657 | except Exception as e: |
| 22658 | if not self.silent_on_error: |
| 22659 | _error_popup_with_traceback('UserSettings.save error', '*** UserSettings.save() Error saving settings to file:***\n', self.full_filename, e) |
| 22660 | |
| 22661 | return self.full_filename |
| 22662 | |
| 22663 | def load(self, filename=None, path=None): |
| 22664 | """ |
no test coverage detected