[orca/new-settings] Renamed back the backends as [backendName]_backend so the imports don't get confused with the actual



commit 4c2ba0e6c17b1c7eab61dc1f97a95e3177713f8f
Author: Juanje Ojeda <jojeda emergya es>
Date:   Mon Oct 25 06:47:13 2010 +0200

    Renamed back the backends as [backendName]_backend so the imports don't get confused with the actual [backendName] libs

 src/orca/backends/Makefile.am                      |    6 +++---
 .../backends/{classic.py => classic_backend.py}    |    0
 src/orca/backends/{gconf.py => gconf_backend.py}   |    0
 src/orca/backends/{yaml.py => yaml_backend.py}     |    8 ++++----
 src/orca/orca.py                                   |    9 ++++-----
 src/orca/settings_manager.py                       |    8 ++++----
 6 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/src/orca/backends/Makefile.am b/src/orca/backends/Makefile.am
index 37f3ac6..f660110 100644
--- a/src/orca/backends/Makefile.am
+++ b/src/orca/backends/Makefile.am
@@ -2,9 +2,9 @@ orca_pathdir=$(pyexecdir)
 
 orca_python_PYTHON = \
         __init__.py \
-        classic.py \
-        gconf.py\
-        yaml.py
+        classic_backend.py \
+        gconf_backend.py\
+        yaml_backend.py
 
 orca_pythondir=$(pyexecdir)/orca/backends
 
diff --git a/src/orca/backends/classic.py b/src/orca/backends/classic_backend.py
similarity index 100%
rename from src/orca/backends/classic.py
rename to src/orca/backends/classic_backend.py
diff --git a/src/orca/backends/gconf.py b/src/orca/backends/gconf_backend.py
similarity index 100%
rename from src/orca/backends/gconf.py
rename to src/orca/backends/gconf_backend.py
diff --git a/src/orca/backends/yaml.py b/src/orca/backends/yaml_backend.py
similarity index 95%
rename from src/orca/backends/yaml.py
rename to src/orca/backends/yaml_backend.py
index 9a8f43e..0f12ab5 100644
--- a/src/orca/backends/yaml.py
+++ b/src/orca/backends/yaml_backend.py
@@ -26,7 +26,7 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2010 Consorcio Fernando de los Rios."
 __license__   = "LGPL"
 
-import yaml
+from yaml import load, dump
 import os
 from xdg.BaseDirectory import xdg_data_home
 
@@ -46,7 +46,7 @@ class Backend():
                  'pronunciations': pronunciations,
                  'keybindings': keybindings}
         settingsFile = open(self.settingsFile, 'w')
-        yaml.dump(prefs, settingsFile)
+        dump(prefs, settingsFile)
         settingsFile.close()
 
     def saveProfileSettings(self, profile, general,
@@ -60,12 +60,12 @@ class Backend():
                  'pronunciations': pronunciations,
                  'keybindings': keybindings}
         settingsFile = open(self.settingsFile, 'w')
-        yaml.dump(prefs, settingsFile)
+        dump(prefs, settingsFile)
         settingsFile.close()
 
     def _getSettings(self):
         settingsFile = open(self.settingsFile)
-        prefs = yaml.load(settingsFile)
+        prefs = load(settingsFile)
         self.general = prefs['general']
         self.pronunciations = prefs['pronunciations']
         self.keybindings = prefs['keybindings']
diff --git a/src/orca/orca.py b/src/orca/orca.py
index c638cc4..8dec320 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -112,7 +112,8 @@ EXIT_CODE_HANG = 50
 #
 _userSettings = None
 _settingsManager = SettingsManager()
-_settingsManager.loadBackend()
+if _settingsManager is None:
+    die()
 
 # Command line options that override any other settings.
 #
@@ -1132,8 +1133,7 @@ def loadUserSettings(script=None, inputEvent=None):
     reloaded = False
     if _userSettings:
         try:
-            _userSettings = _settingsManager.loadSettings() 
-            #reload(_userSettings)
+            _userSettings = _settingsManager.getGeneralSettings()
             reloaded = True
         except ImportError:
             debug.printException(debug.LEVEL_FINEST)
@@ -1141,8 +1141,7 @@ def loadUserSettings(script=None, inputEvent=None):
             debug.printException(debug.LEVEL_SEVERE)
     else:
         try:
-            _userSettings = _settingsManager.loadSettings()
-            #_userSettings = __import__("user-settings")
+            _userSettings = _settingsManager.getGeneralSettings()
             if _debugSwitch:
                 debug.debugLevel = debug.LEVEL_ALL
                 debug.eventDebugLevel = debug.LEVEL_OFF
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index 574de26..66a0283 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -65,6 +65,7 @@ class SettingsManager():
         self.keybindings = {}
 
         if not self._loadBackend():
+            #TODO: Try to return None when the object is created if this fails
             return None
 
         self._backend = self.backendModule.Backend()
@@ -84,10 +85,9 @@ class SettingsManager():
         """Load specific backend for manage user settings"""
 
         try:
-            self.backendModule = __import__('backends.%s' % self.backendName, \
-                                            globals(),
-                                            locals(),
-                                            self.backendName)
+            backend = 'orca.backends.%s_backend' % self.backendName
+            self.backendModule = __import__(backend, globals(), locals(),
+                                            backend, -1)
             print '\nImporting %s backend OK!' % self.backendName
             return True
         except:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]