[orca/new-settings] Fix availableProfiles in YAML Backend. Added comments in the YAML Backend.
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/new-settings] Fix availableProfiles in YAML Backend. Added comments in the YAML Backend.
- Date: Tue, 26 Oct 2010 11:08:43 +0000 (UTC)
commit b29e76815a94077d322f57e5e7824de7ce94113d
Author: Alejandro Leiva <aleiva emergya es>
Date: Tue Oct 26 12:48:25 2010 +0200
Fix availableProfiles in YAML Backend. Added comments in the YAML Backend.
src/orca/backends/yaml_backend.py | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/backends/yaml_backend.py b/src/orca/backends/yaml_backend.py
index 9f37980..d124740 100644
--- a/src/orca/backends/yaml_backend.py
+++ b/src/orca/backends/yaml_backend.py
@@ -30,17 +30,23 @@ from yaml import load, dump
import os
from xdg.BaseDirectory import xdg_data_home
+
class Backend:
def __init__(self):
+ """ Initialize the YAML Backend.
+ """
self.general = {}
self.pronunciations = {}
self.keybindings = {}
self.profiles = {}
self.settingsFile = os.path.join(xdg_data_home,
"orca/user-settings.conf")
+ self._getSettings()
def saveDefaultSettings(self, general, pronunciations, keybindings):
+ """ Save default settings for all the properties from
+ orca.settings. """
prefs = {'general': general,
'profiles': { 'default': { 'profile': ['Default', 'default'],
'pronunciations': {},
@@ -55,6 +61,8 @@ class Backend:
def saveProfileSettings(self, profile, general,
pronunciations, keybindings):
+ """ Save minimal subset defined in the profile against current
+ defaults. """
if profile is None:
profile = 'default'
@@ -72,6 +80,7 @@ class Backend:
settingsFile.close()
def _getSettings(self):
+ """ Load from config file all settings """
settingsFile = open(self.settingsFile)
prefs = load(settingsFile)
self.general = prefs['general']
@@ -80,6 +89,8 @@ class Backend:
self.profiles = prefs['profiles']
def getGeneral(self, profile='default'):
+ """ Get general settings from default settings and
+ override with profile values. """
self._getSettings()
generalSettings = self.general
profileSettings = self.profiles[profile]
@@ -89,6 +100,8 @@ class Backend:
return generalSettings
def getPronunciations(self, profile='default'):
+ """ Get pronunciation settings from default settings and
+ override with profile values. """
self._getSettings()
pronunciations = self.pronunciations
profileSettings = self.profiles[profile]
@@ -97,6 +110,8 @@ class Backend:
return pronunciations
def getKeybindings(self, profile='default'):
+ """ Get keybindings settings from default settings and
+ override with profile values. """
self._getSettings()
keybindings = self.keybindings
profileSettings = self.profiles[profile]
@@ -105,14 +120,19 @@ class Backend:
return keybindings
def isFirstStart(self):
+ """ Check if we're in first start. """
if os.path.exists(self.settingsFile):
return False
else:
return True
def availableProfiles(self):
+ """ List available profiles. DEPRECATED? """
+ self._getSettings()
profiles = []
- for key in self.profiles.keys():
- profiles.append([key.title(), key])
+
+ for profileName in self.profiles:
+ profileDict = self.profiles[profileName]
+ profiles.append(profileDict['profile'])
return profiles
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]