[orca/new-settings] Rewritten the method saveProfileSettings() to simplify it and be sure we don't change anythngs outsi
- From: Juanje Ojeda Croissier <jojeda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Rewritten the method saveProfileSettings() to simplify it and be sure we don't change anythngs outsi
- Date: Mon, 1 Nov 2010 17:39:27 +0000 (UTC)
commit 7d082752c9938fd6df84363320b3a5cc69aab166
Author: Juanje Ojeda <jojeda emergya es>
Date: Mon Nov 1 17:59:13 2010 +0100
Rewritten the method saveProfileSettings() to simplify it and be sure we don't change anythngs outside that profile.
src/orca/backends/yaml_backend.py | 27 ++++-----------------------
1 files changed, 4 insertions(+), 23 deletions(-)
---
diff --git a/src/orca/backends/yaml_backend.py b/src/orca/backends/yaml_backend.py
index 77f6c25..9148b89 100644
--- a/src/orca/backends/yaml_backend.py
+++ b/src/orca/backends/yaml_backend.py
@@ -69,35 +69,16 @@ class Backend:
pronunciations, keybindings):
""" Save minimal subset defined in the profile against current
defaults. """
-
if profile is None:
profile = 'default'
general['pronunciations'] = pronunciations
general['keybindings'] = keybindings
- # We're going to update the dictionary
- profilePrefs = self.profiles.copy()
- newProfilePrefs = {profile: general}
- profilePrefs.update(newProfilePrefs)
-
- for profilePrefsKey, profilePrefsValue in profilePrefs.items():
- profiles = self.profiles.get(profilePrefsKey, dict())
- profiles.update(profilePrefsValue)
- profilePrefsValue = profiles.copy()
-
- currentProfile = profilePrefs.get(profile)
- currentProfile['pronunciations'] = pronunciations
- currentProfile['keybindings'] = keybindings
- profilePrefs.update({profile: currentProfile})
-
- prefs = {'general': self.general,
- 'profiles': profilePrefs,
- 'pronunciations': self.pronunciations,
- 'keybindings': self.keybindings}
- settingsFile = open(self.settingsFile, 'w')
- dump(prefs, settingsFile)
- settingsFile.close()
+ with open(self.settingsFile, 'r+') as settingsFile:
+ prefs = load(settingsFile)
+ prefs['profiles'][profile] = general
+ dump(prefs, settingsFile)
def _getSettings(self):
""" Load from config file all settings """
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]