[orca/new-settings] * Added importProfile method * Get profile from prefs['profile'] key in saveSettings
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] * Added importProfile method * Get profile from prefs['profile'] key in saveSettings
- Date: Thu, 28 Oct 2010 15:37:29 +0000 (UTC)
commit 519ac2e5538c3db68b448c357f5c7bcde301f402
Author: Javier Hernández Antúnez <jhernandez emergya es>
Date: Thu Oct 28 15:15:08 2010 +0200
* Added importProfile method * Get profile from prefs['profile'] key in saveSettings
src/orca/settings_manager.py | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 403231a..6309e9b 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -32,6 +32,8 @@ import os
from keybindings import KeyBinding, KeyBindings
+from yaml import load, dump
+
class SettingsManager():
"""Settings backend manager. This class manages orca user's settings
using different backends"""
@@ -284,7 +286,7 @@ class SettingsManager():
"""Let the active backend to store the default settings and
the profiles' ones."""
# Assign current profile
- (currentProfileString, currentProfile) = general.get('activeProfile')
+ (currentProfileString, currentProfile) = general.get('profile')
self.profile = currentProfile
# The default settings should already exist but we save them anyway
@@ -357,6 +359,26 @@ class SettingsManager():
return self._backend.availableProfiles()
+ def importProfile(self, fileName):
+ """Import profile from a given filename"""
+
+ profileFile = open(fileName)
+ prefs = load(profileFile)
+
+ general = {}
+
+ for key, value in prefs.items():
+ if key not in ['pronunciations', 'keybindings']:
+ general[key] = value
+
+ pronunciations = prefs['pronunciations']
+ keybindings = prefs['keybindings']
+ profile = prefs['profile']
+
+ self.saveSettings(general,
+ pronunciations,
+ keybindings)
+
def getVoiceKey(voice):
voicesKeys = getattr(settings, 'voicesKeys')
for key in voicesKeys.keys():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]